Linux installation

How to install Mango in Linux

August 26th, 2021


Linux is the preferred operating system for running Mango in production environments. Mango works on a wide variety of Linux distributions and architectures.

Note: We also provide an installation script which will download and configure Mango for you.

Additionally, if you are using a RHEL distribution, we recommend using the installation script as the following instructions are manual instructions for users who are familiar with Linux and only shows commands relative to the apt-get package manager.

Requirements

  • Java JDK 11 is installed and either:
    • JAVA_HOME environment variable points to the JDK installation directory
    • The JDK bin directory is available on your path (specifically the java command is available)

You can run the following commands on any linux system that uses the apt package manager (such as Debian/Ubuntu) to install JDK 11:

sudo apt update
sudo apt install openjdk-11-jdk-headless

Installation

These instructions assume that you will install Mango as root, you should switch to the root user or prefix the commands with sudo. If you do not have root access you can still install Mango under your home directory and run it as yourself.

Create an installation directory

mkdir /opt/mango

Set a system wide mango_paths_home environment variable (recommended but not required)

echo 'mango_paths_home=/opt/mango' >> /etc/environment

Create a user for Mango

You should create a user for Mango to run under. Never run Mango as root.

useradd --system --home-dir /opt/mango --shell /bin/false mango

Download Mango

Download a full core zip file from the Store. Copy the zip file to your home directory.

Extract the zip file to the installation directory

If you do not already have it installed, install the unzip package for Debian/Ubuntu:

apt-get install unzip

Extract the zip file

  • Enterprise Version
unzip enterprise-m2m2-core-4.0.0.zip -d /opt/mango
  • Free Version
unzip free-m2m2-core-4.0.0.zip -d /opt/mango

Set the correct owner on the installation directory

chown -R mango:mango /opt/mango

Configure Mango

Edit mango.properties and configure Mango, see the installation configuration page for more details.

nano /opt/mango/mango.properties

Configure Java options for starting Mango

You can set Java command line options such as memory limits, debug options, garbage collection settings etc by modifying the start-options.sh script in the mango/bin directory. Un-comment lines to configure various Java command line options.

Note: Configuring these settings was previously accomplished via the start extensions (ext-enabled directory), as of Mango 4.0.0 and when using the start-mango.sh script these extensions are no longer used.

Manually starting and stopping Mango

At this point you can manually start Mango, however we recommend you install a service instead (see below).

To manually start Mango:

cd $mango_paths_data
sudo -u mango bin/start-mango.sh

Running Mango:

  1. Once mango has started, you can log into the dashboard by opening your browser and going to localhost:8080.
  2. The default username and password are both "admin".

To manually stop Mango:

cd $mango_paths_data
sudo -u mango bin/stop-mango.sh

Note: Never run Mango as root, this is a security risk and will also result in files in /opt/mango having the incorrect owner. If you do accidentally run Mango as root, stop Mango and run:

chown -R mango:mango /opt/mango

Installing Mango as a service

Note: Previously Mango used to restart itself via a script. Mango no longer does this, if you want Mango to restart automatically you should start it via systemd. Most modern Linux systems come with systemd installed.

cp /opt/mango/bin/mango.service /etc/systemd/system/

You may wish to edit the service file if you have used a different installation directory or user than the instructions above. Default mango.service file contents:

[Unit]
Description=Mango Automation
After=mysqld.service
StartLimitIntervalSec=0

[Service] EnvironmentFile=/etc/environment Type=forking WorkingDirectory=/opt/mango PIDFile=/opt/mango/bin/ma.pid ExecStart=/opt/mango/bin/start-mango.sh SuccessExitStatus=0 SIGINT SIGTERM 130 143 Restart=always RestartSec=5s User=mango NoNewPrivileges=true

[Install] WantedBy=multi-user.target

Now enable the service:

systemctl enable mango

You have now enabled mango to start at system startup.

To stop/start/restart the Mango service

systemctl stop mango
systemctl start mango
systemctl restart mango

To get the Mango service status

systemctl status mango

Copyright © 2024 Radix IoT, LLC.