Skip to content
Bots!
Bots!
  • About
    • Myself
    • আমার দোয়া
  • Bookmarks
    • Bookmarks
    • My OCI Bookmarks
    • Useful Proxmox Commands & Links
    • Learning Nano
    • Useful Sites
    • Useful Virtualbox Command
    • Useful MySQL Command
    • Useful Linux Command
    • BTT-CAS
  • Resources
    • Webinar on Cloud Adoption for Project Managers
  • Photos
  • Videos
  • Downloads
Bots!

Install Librenms on Ubuntu 16.04

Rumi, March 17, 2018September 4, 2018

The first step we must do for installing LibreNMS Monitoring Tools is to install some packages needed on the server. Connect to your server and update the repository.

ssh root@hakase-labs-server
sudo apt update

Install all the required packages for LibreNMS from the Ubuntu repository using the following command.

apt-get install fping imagemagick whois mtr-tiny nmap python-mysqldb snmpd  rrdtool git snmp graphviz python lsb snmp

After the installation is complete, goto the next step.

Install Nginx Webserver
In this tutorial, we will be running LibreNMS under the Nginx web server. Nginx is powerful web server that’s available in the Ubuntu repositories.

Install nginx using apt command from the repository in the following way.

apt install nginx

When it’s done, start the service and enable it to run automatically every time at system boot.

systemctl start nginx
systemctl enable nginx

Nginx web server is running under the default port 80. We can check the port using the netstat command, and check Nginx using curl command to get the HTTP status code, as shown below.

netstat -plntu | grep 80
curl -I localhost

Nginx installation has been completed.

Install and Configure PHP-FPM
LibreNMS is PHP based web application monitoring tool. It offers support for new PHP version 7.0, and we will be using it for this guide.

Install PHP, PHP-FPM, and all extensions/modules needed for LibreNMS installation using the apt command below.

apt-get install php7.0-cli php7.0-mysql php7.0-gd php7.0-snmp php-pear php7.0-curl php7.0-fpm php7.0-mcrypt php7.0-json php-net-ipv4 php-net-ipv6

Next, we need to add some configuration to php.ini files. We need to define the default timezone in php.ini file and make sure the timezone matches with the current timezone used by the system.

Check the currently timezone used by the system with the following command.

timedatectl
You should get a result similar to the following.

You can see the server is using the ‘Asia/Dhaka’ timezone.

Now go to the PHP configuration directory and edit php.ini files for the cli and fpm config.

cd /etc/php/7.0/
vim fpm/php.ini
vim cli/php.ini

Uncomment the ‘date.time’ line and change the value with our system timezone ‘Asia/Dhaka’

date.time = Asia/Dhak

Uncomment cgi configuration below, change the value to 0.

cgi.fix_pathinfo = 0

Save and exit.

All configuration is complete. Now start the service and enable it to launch every time at system boot using the following systemctl commands.

systemctl start php7.0-fpm
systemctl enable php7.0-fpm

PHP-FPM is now running on ubuntu server – it’s running under the sock file. Check it with the netstat command.

netstat -pl | grep php

Install and Configure MariaDB
In this step, we will install the mariadb-server for the LibreNMS database. We will install, configure and create a new database and a new user for the LibreNMS installation. Install mariadb-server from ubuntu repository using the apt command below.

apt-get install mariadb-server mariadb-client mariadb

When it’s done, start the service, and enable it to run automatically at system boot, something you can do using the following systemctl commands.

systemctl start mysql
systemctl enable mysql

The database server mariadb is now running. Next we need to configure the root password for mariadb. We can use the ‘mysql_secure_installation’ command below to configure the root password.

mysql_secure_installation

You will be asked about the new root password – type your password and press ‘Enter’ to continue.

Set root password? [Y/n] Y
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y
The root password for mariadb has been configured.

Next, we must create a new database and user for LibreNMS. We will create a new database named ‘librenms’, a new user named ‘librenms’ with password ‘hakase-labs123’.

Log in to the mariadb shell using the following command.

mysql -u root -p

Type the ROOT Password:

Run mariadb queries below to create a new database and user, and grant all privileges on the database to the new user.

CREATE DATABASE librenms CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE USER 'librenms'@'localhost' IDENTIFIED BY 'hakase-labs123';
GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'localhost';
FLUSH PRIVILEGES;

A new database and user for LibreNMS has been created.

For the LibreNMS installation, we need to add some configuration to the configuration file. Go to the ‘/etc/mysql/’ directory and edit the mariadb configuration file.

cd /etc/mysql/
vim mariadb.conf.d/50-server.cnf

Paste configuration below under the ‘[mysqld]’ section.

innodb_file_per_table=1
sql-mode=""
lower_case_table_names=0

Save and exit.

Now apply the new configuration by restarting the service.

systemctl restart mysql

The mariadb database configuration has been completed.

Download and Configure LibreNMS
In this step, we will configure the system for LibreNMS installation.

– Add New User and Download LibreNMS

Create a new system user named ‘librenms’, define ‘/opt/librenms’ as the default home directory for the user, and assign the new ‘librenms’ user to the www-data group.

Run the following command to do it all.

useradd librenms -d /opt/librenms -M -r
usermod -a -G librenms www-data

Now go to the ‘/opt/’ directory and download the LibreNMS source code using the git command.

cd /opt/
git clone https://github.com/librenms/librenms.git librenms

Next, create a new directory for libreNMS log files and rrd files.

mkdir -p /opt/librenms/{logs,rrd}

Change ownership permissions for the ‘rrd’ directory to ‘775’, and change the owner of the ‘librenms’ directory to the ‘librenms’ user and group.

chmod -R 775 /opt/librenms/rrd/
chown -R librenms:librenms /opt/librenms/

A new ‘librenms’ has been created, and the LibreNMS source code has been downloaded.

– Configure LibreNMS Virtualhost

Go to the ‘nginx’ configuration directory and create a new virtual host file ‘librenms’ with vim

cd /etc/nginx/
vim sites-available/librenms

Paste the following LibreNMS Virtual host configuration there.

server {

    # Add your own domain name
    listen      80;
    server_name librenms.irsyadf.me;

    # LibreNMS Webroot directory
    root        /opt/librenms/html;
    index       index.php;

    # LibreNMS logs
    access_log  /opt/librenms/logs/access_log;
    error_log   /opt/librenms/logs/error_log;

   # Enabling Gzip compression on Nginx
    charset utf-8;
    gzip on;
    gzip_types text/css application/javascript text/javascript application/x-javascript image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location /api/v0 {
        try_files $uri $uri/ /api_v0.php?$query_string;
    }

    # PHP-FPM handle all .php files requests
    location ~ \.php {
        include fastcgi.conf;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }

    location ~ /\.ht {
        deny all;
    }

}

Save and exit. Now, activate the virtualhost.

ln -s /etc/nginx/sites-available/librenms /etc/nginx/sites-enabled/

Test the nginx configuration and make sure there is no error. Then restart the service.

nginx -t
systemctl restart nginx

– Configure UFW Firewall

Add new ports to the firewall. Add new ssh, http, https and the port used by snmpd 161 udp type to the ufw firewall.

Run the following ufw commands.

ufw allow ssh
ufw allow http
ufw allow https
ufw allow 161/udp

Start the ufw firewall with the ufw enable command as shown below.

ufw enable

Type ‘y’ and press ‘Enter’ to confirm. Start and enable it to launch every time at system boot.

If you want to see the firewall status, run the ‘ufw status’ command.

ufw status

You will get the firewall status – active or inactive – and the list of ports and service added to the firewall.

Configure snmpd

cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf
vi /etc/snmp/snmpd.conf

Edit the text which says RANDOMSTRINGGOESHERE and set your own community string.

curl -o /usr/bin/distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro
chmod +x /usr/bin/distro
systemctl restart snmpd

Cron job

cp /opt/librenms/librenms.nonroot.cron /etc/cron.d/librenms

Copy logrotate config

LibreNMS keeps logs in /opt/librenms/logs. Over time these can become large and be rotated out. To rotate out the old logs you can use the provided logrotate config file:

cp /opt/librenms/misc/librenms.logrotate /etc/logrotate.d/librenms

Set permissions

chown -R librenms:librenms /opt/librenms
setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
setfacl -R -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/

LibreNMS Web Installer
After all the above steps are complete, we need to install LibreNMS through the web browser. Open your web browser, type the LibreNMS domain name ‘librenms.hakase-labs.co’ in the address bar and press Enter.

– Checking PHP Modules

You will be redirected to the install.php page showing the result of PHP module support checks. Make sure all status is green as shown below.

Click ‘Next Stage’ to continue.

– Database Configuration

Fill all the database info with your own db.

DB User: librenms
DB Pass: hakase-labs123
DB Name: librenms

And click ‘Next Stage’.

– Importing MySQL Database

Wait for the installer script to import sample of database to our database – do not close the browser tab during this process.

After all db is imported, click ‘Goto Add User’.

– Add Admin User

Here, type your admin user, email, and password.

Click ‘Add User’.

– Generate LibreNMS Config

Click the ‘Generate Config’ button.

And you will get a config file similar to the one shown below.

Copy the php config script, and come back to your ssh session. Goto the ‘/opt/librenms’ directory and create the ‘config.php’ file manually using vim.

cd /etc/librenms/
vim config.php

Paste the configuration there, and change the ownership of the file to librenms user and group.

chown librenms:librenms config.php

Back to your web browser and click the ‘Finish Install’ button. Now you get to the last page from the librenms web installer – see below.

Final configuration
After the installation through web browser is complete, we need to do some other steps.

– Configure SNMP

Backup default configuration file and copy the sample configuration to the ‘/etc/snmp/’ directory.

mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.aseli
cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf

Edit the new configuration with vim.

vim /etc/snmp/snmpd.conf

Replace the ‘RANDOMSTRINGGOESHERE’ line with your own community name ‘hakaselabs’, as shown below.

com2sec readonly  default         hakaselabs

Save and exit.

Next, we need to download the distro detection script. Download it using curl, then make the script executable, then finally, restart the snmp service.

curl -o /usr/bin/distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro
chmod +x /usr/bin/distro
systemctl restart snmpd

– Crontab and Logrotate Configuration

Goto the librenms directory and copy sample configuration for Crontab and Logrotate.

cd /opt/librenms/

Copy the configuration.

cp librenms.nonroot.cron /etc/cron.d/librenms
cp misc/librenms.logrotate /etc/logrotate.d/librenms

Now restart the cron service and reload the logrotate configuration.

systemctl restart cron
logrotate -f /etc/logrotate.conf

– Validate Configuration

Wait for some time until the cron script is running on the system. Once that is done, validate with ‘validate.php’ script.

Goto the librenms directory and run the validate script.

cd /opt/librenms/
./validate.php

If your installation is correct, you will get the result as shown below.

LibreNMS Installation with Nginx Webserver on Ubuntu 16.04 is complete.

Src:
https://www.howtoforge.com/tutorial/how-to-setup-librenms-monitoring-tools-with-nginx-on-ubuntu-1604-lts/
https://docs.librenms.org/
https://docs.librenms.org/#Installation/Installation-Ubuntu-1804-Nginx/#final-steps

Administrations Configurations (Linux) LibreNMSUbuntuUbuntu 16.04

Post navigation

Previous post
Next post

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Myself…

Hi, I am Hasan T. Emdad Rumi, an IT Project Manager & Consultant, Virtualization & Cloud Savvyfrom Dhaka, Bangladesh. I have prior experience in managing numerous local and international projects in the area of Telco VAS & NMC, National Data Center & PKI Naitonal Root and CA Infrastructure. Also engaged with several Offshore Software Development Team.

Worked with Orascom Telecom-Banglalink, Network Elites as VAS partner, BTRC, BTT (Turkey) , Mango Teleservices Limited and Access to Informaiton (A2I-UNDP)

Currently working at Oracle Corporation as Principal Technology Solution and Cloud Architect.

You can reach me [h.t.emdad at gmail.com] and I will be delighted to exchange my views.

Tags

Apache Bind Cacti CentOS CentOS 6 CentOS 7 Debain Debian Debian 10 Debian 11 Debian 12 DKIM Docker endian icinga iptables Jitsi LAMP Letsencrypt Linux Munin MySQL Nagios Nextcloud NFS nginx pfsense php Postfix powerdns Proxmox RDP squid SSH SSL Ubuntu Ubuntu 16 Ubuntu 18 Ubuntu 20 Varnish virtualbox vpn Webmin XCP-NG zimbra

Topics

Recent Posts

  • Install Jitsi on Ubuntu 22.04 / 22.10 April 30, 2025
  • Key Lessons in life April 26, 2025
  • Create Proxmox Backup Server (PBS) on Debian 12 April 19, 2025
  • Add Physical Drive in Proxmox VM Guest April 19, 2025
  • Mount a drive permanently with fstab in Linux April 16, 2025
  • Proxmox 1:1 NAT routing March 30, 2025
  • Installation steps of WSL – Windows Subsystem for Linux March 8, 2025
  • Enabling Nested Virtualization In Proxmox March 8, 2025
  • How to Modify/Change console/SSH login banner for Proxmox Virtual Environment (Proxmox VE / PVE) March 3, 2025
  • Install Proxmox Backup Server on Debian 12 February 12, 2025

Archives

Top Posts & Pages

  • Install Jitsi on Ubuntu 22.04 / 22.10
©2025 Bots! | WordPress Theme by SuperbThemes