How to compile and use the Lua powered Mako Server

Posted by SurfskiDude on Nov 27, 2022 10:33 AM EDT
SurfskiDude
Mail this story
Print this story

Lua is a small, lean, and fast scripting language ideal for working with web servers, especially on small Linux devices and low end Virtual Private Servers.

The Mako Server provides a compact and efficient Lua web framework and non-blocking asynchronous sockets in a tiny ready to run application server package. The Mako Server is a good fit for embedded Linux systems such as the Raspberry Pi. Lua is a powerful and fast programming language that is easy to learn and use.

Make sure you have the following tools installed:

sudo apt install git make gcc unzip

The first thing we need to do is to clone the Barracuda App Server (BAS) GitHub repo. This repo includes the Mako Server. In short, BAS is a web server C library and the Mako Server is a ready to run web server based on the BAS library.

You can now just run the makefile as follows:

make -f mako.mk

However, let's add a few modules. Lua and the Mako Server can easily be extended and the makefile is set up for compiling two additional common modules: the SQLite database engine and Google's Protocol Buffers. When added, you have access to additional APIs from Lua.

cd src;
git clone https://github.com/starwing/lua-protobuf.git 

wget https://www.sqlite.org/2022/sqlite-amalgamation-3400000.zip; unzip sqlite-amalgamation-3400000.zip;

#Move the SQLite source to the BAS/src directory

cd sqlite-amalgamation-3400000/; mv *.c *.h ..
Note: you may want to check that you are downloading the latest SQLite version: https://www.sqlite.org/download.html

Now, navigate to the BAS/ directory and run make.

cd ../../;
make -f mako.mk
You can now run the Mako Server

./mako

The server typically opens port 9357 (when started as non root) so you can now navigate to http://localhost:9357

You should see the built in intro page.

Now stop the server (CTRL-C) and download the tutorials as follows:

git clone https://github.com/RealTimeLogic/LSP-Examples.git

The example repo includes many examples so let's just try one of the examples, the web shell example:

./mako -l::LSP-Examples/Web-Shell/www

You should see a Linux web based shell (web based SSH) if you navigate to http://localhost:9357

This was a quick introduction. For more, use the following tutorials and documentation:

Online Lua REPL: https://tutorial.realtimelogic.com/Lua-Types.lsp Tutorials: https://makoserver.net/tutorials/

Online documentation: https://realtimelogic.com/ba/doc/

BAS can also be compiled for deep embedded RTOS systems such as the ESP32 microcontroller. Here are two additional tutorials you may find interesting if you work with RTOS powered devices:

ESP32 tutorial: https://realtimelogic.com/downloads/bas/ESP32/ NXP's RT1020 tutorial: https://realtimelogic.com/downloads/bas/rt1020/





  Nav
» Read more about: Story Type: Tutorial; Groups: ARM, Developer, Embedded, Linux, Raspberry Pi

« Return to the newswire homepage

This topic does not have any threads posted yet!

You cannot post until you login.