Installing Mako Server as a Service on Linux

Installing Mako Server as a service (aka daemon) on Linux is straightforward. The following example shows how to create a dedicated user for the Mako Server and create a boot script that starts the Mako Server when Linux starts. This script also enables you to start/stop the service from the command line.

If you want to quickly install the Mako Server as a Linux daemon, you may use the cloud server installation script if you are installing the server on an X86 type CPU.

Running the Mako Server in the background is super easy, all you have to do is to add the -d switch:

mako -d additional-commands

Starting the Mako Server in the background as shown above makes the server run until Linux reboots. We can automate the Mako Server startup when Linux powers on by either creating an init.d script or a systemd script. This tutorial focuses on creating an init.d script. If you prefer systemd and if you have Ansible experience, check out the SharkTrust Installer, which shows how to automatically install the Mako Server and how to auto start the server using systemd.

Getting Started

Note, all commands below must be run as user root. If you are not root, you can become root by using the command su or sudo sh.

First, we need to download and install the Mako Server. You can skip this step if you have already copied Mako Server to your /usr/bin directory. The following commands download Mako Server for x86 (32 or 64) bit. For other platforms, download the appropriate version or cross compile the source for your target platform.

Copy the following commands and paste into your terminal window.

cd /tmp; export XBIT=`getconf LONG_BIT`; wget$XBIT.tar.gz; tar xvzf mako.linux-x$XBIT.tar.gz; cp mako /usr/bin;

The next step is to create a dedicated user for the Mako Server. We will use the name 'mako' as the Linux user. You can choose any username or simply run the server under your existing user account. However, you must modify the service script (downloaded in the next step) if you use a username other than 'mako'.

useradd -G daemon -m -s /bin/bash mako

You should now have a new user with the home directory /home/mako. We are now ready to install the Mako Server's boot script. This script starts the Mako Server as a Linux service (aka daemon) -- that is, the server runs in the background.

Copy the following instructions into your terminal window to install the startup script.

cd /etc/init.d/; wget; chmod +x; cd;

You should now be able to start and stop the Mako Server as a background process from the command line:

/etc/init.d/ start /etc/init.d/ stop

Although you can start and stop the server from the command line, the server will not start if you reboot your Linux computer. For this to work, the following command must be run:

update-rc.d defaults

Configuring Your First Application

If you started Mako Server as instructed above, you will get a 404 not found response if you visit the server using a browser. We need to install at least one LSP application in the server. The following example shows how to create one app that simulates a standard web server's www directory.

Run the following command in your console Window:

su mako; cd; whoami;

You should now be running as the user 'mako' and be in the /home/mako directory. The next step is to create a mako configuration file that loads one app. You can use any editor when creating the configuration file. We are using the 'nano' editor in the following example. If you get an error when running nano, install nano as follows: apt-get install nano.

nano mako.conf

When nano is running, copy the following and paste into the nano editor.

apps = { { name="", path="www", dav=true, auth=true }, } users = { mako="123456" } tracelogger = { auth=true }

Using the nano editor, modify the username "mako" to your username and the password "123456" to a more suitable password. Press Ctrl-X and save the file (Y). You should now be back at the command prompt.

The above configuration file sets up one root application using the path 'www' (that is /home/mako/www). We must create this directory before restarting the server. Type the following command at the Linux command prompt.

mkdir www

We can now restart the server. The two following commands exit user mako (back to root) and restart the server.

exit; /etc/init.d/ restart;

You will still get a 404 page if you visit the server using a browser. What we need is an index page in the new www directory.

Create index.lsp in the www directory.

Map/mount the server using WebDAV if the Mako Server runs on an online VPS (cloud server)

To map/mount the online server as a file system, use the URL: http://server-address/dav/. In Windows, you can go to Map Network Drive and enter the URL to map the online server as a drive in Windows. See the WebDAV information page for the BarracudaDrive product for more information on how to map/mount a WebDAV drive. The above Mako Server configuration script (mako.conf) enabled WebDAV for your application. The WebDAV username/password (default mako/123456) is what you put into the modified Mako Server configuration script.

When you have mapped/mounted WebDAV, use any editor on your host computer (PC) and open/create a new file on the mapped/mounted drive.

The following example shows how to do this on Windows using Notepad. The online server is mapped as 'Z:'.

notepad z:\index.lsp

Copy the following content into the editor (index.lsp) and save the file.

<h1><?lsp print"Hello Browser" trace"Hello Trace" ?></h1>

You should now see "Hello Browser" if you visit your home page using your browser.

Function trace would normally print to the console, but you have no console when the server runs as a background service. The Mako Server inserts the information printed to the console into the file mako.log when the server runs as a background service. This log can also be viewed in real time if the TraceLogger is enabled. The TraceLogger was enabled in the above Mako Server configuration script. Navigate to http://servername/rtl/tracelogger/ and login using the credentials you entered when you modified the mako configuration file. You should see the following:


Notice how the message "Hello Trace" and the line number is printed each time you navigate (using a different browser window) to your main index page.

Hash Encrypted Passwords

We stored the passwords in clear text in the above Mako Server configuration file (mako.conf). You can also store the passwords as an MD5 hash. The MD5 hash must be computed as explained in the Barracuda App Server manual: Storing passwords as a hash value.

You may use the following LSP script to simplify the calculations. Copy the following content and paste it into an LSP page that you can run on your server instance.

<?lsp local d = request:data() if d.u and d.p then local realm="Barracuda Server" -- For Mako Server DAV and TraceLogger local ha1=ba.crypto.hash"md5"(d.u)":"(realm)":"(d.p)(true,"hex") response:write(d.u,'={"',ha1,'"}') else print"Username and password required" end ?>

When you run the page, enter the following:


'mako' and '123456' must be substituted with your own credentials.

Executing the page with the above credentials produces the following result:


Copy the produced result and paste into mako.conf:

users = { mako={"072fa416feb977c8c2d7464e50a32122"} }

Installing Mako Server on an Online VPS

The tutorial Setting up an IoT Broker explains how to install the Mako Server on a low cost online VPS.

Engineers: We're Here to Support Your Vision:

Navigating the world of embedded web servers and IoT can be daunting. Our consulting services are here to provide instant expertise. But our tutorials are ready if you're looking for a self-paced journey. Every challenge, every ambition, we've got your back.


OPC-UA Client & Server

An easy to use OPC UA stack that enables bridging of OPC-UA enabled industrial products with cloud services, IT, and HTML5 user interfaces.

Edge Controller

Edge Controller

Use our user programmable Edge-Controller as a tool to accelerate development of the next generation industrial edge products and to facilitate rapid IoT and IIoT development.

On-Premises IoT

On-Premises IoT Platform

Learn how to use the Barracuda App Server as your On-Premises IoT Foundation.

Embedded Web Server

Barracuda Embedded Web Server

The compact Web Server C library is included in the Barracuda App Server protocol suite but can also be used standalone.

WebSocket Server

Microcontroller Friendly

The tiny Minnow Server enables modern web server user interfaces to be used as the graphical front end for tiny microcontrollers. Make sure to check out the reference design and the Minnow Server design guide.

WebDAV Server

Network File System

Why use FTP when you can use your device as a secure network drive.

HTTP Client

Secure HTTP Client Library

PikeHTTP is a compact and secure HTTP client C library that greatly simplifies the design of HTTP/REST style apps in C or C++.

WebSocket Client

Microcontroller Friendly

The embedded WebSocket C library lets developers design tiny and secure IoT applications based on the WebSocket protocol.

SMTP Client

Secure Embedded SMTP Library

Send alarms and other notifications from any microcontroller powered product.

Crypto Library

RayCrypto C Library

The RayCrypto engine is an extremely small and fast embedded crypto library designed specifically for embedded resource-constrained devices.

Embedded PKI Service

Automatic SSL Certificate Management for Devices

Real Time Logic's SharkTrust™ service is an automatic Public Key Infrastructure (PKI) solution for products containing an Embedded Web Server.


Modbus TCP client

The Modbus client enables bridging of Modbus enabled industrial products with modern IoT devices and HTML5 powered HMIs.

Posted in Tutorials by bd