How to Install LibreNMS on Ubuntu

Libre has managed to climb the ranks in recent years and is now notorious for its various software. It offers its very own word processor, spreadsheet program, presentation maker, database tool alongside several others aimed at making the life of the daily user more efficient.

Nowadays, it is even compared with Microsoft Office, and several users argue it is better. Nonetheless, it has won the vote of the majority of Linux users. One of its versatile applications comes under the branch of network management. This application is none other than LibreNMS.

LibreNMS acts as an indicator for problems regarding components that may have halted before the problem becomes worse. These applications identify potential anomalies so that they can be checked and rectified on time before causing further issues. LibreNMS is based on PHP and MySQL, which uses the SNMP protocol. It supports a wide range of hardware and operating systems from Hp to Foundry alongside several others.

Now that we have an idea of what LibreNMS is, we move on to its installation process for Ubuntu.

The first step is to update the system so that all drives and required dependencies are at the latest patch. This will prevent any issues down the road that may arise due to outdated versions.

$ sudo apt update

$ sudo apt upgrade

Next, we enable our webserver software, namely Apache. If you don’t have Apache on your system, you may use the following 2 commands provided below.

$ sudo apt-get install apache2

$ systemctl start apache2

$ systemctl enable apache2

The next step is to configure MariaDB. If you don’t have MariaDB installed, you must type in the following command first.

$ sudo apt install mariadb-server mariadb-client

Afterwards, you can check its status with the following.

And enable it.

$ systemctl start mysql

$ systemctl enable mysql

Now, we move to the configuration part. To configure the MariaDB type the command.

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

And add following lines under segment [mysqld]


Once that is done, we start building our database and user for MariaDB. To log in to the server, we type.

$ mysql –u root

Next, we create a database and user by providing the local host password. This is a crucial step, so make sure you have successfully made the localhost as it will be used in all stages to come from here on out.

Another step is to grant all privileges on the database to the user.

To which you get the output:

Now that we have configured MariaDB, we proceed to our next step which is the installation of PHP. First, we add the php repository (in case it was not added already) by using the command.

$ add-apt-repository ppa:ondrej/php

Then install required php packages.

$ apt install wget php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip php-pear php-snmp php-fpm

$ apt-get install php-cli php-mysql php8.0-common php8.0-opcache php-cgi php-bcmath php-imap php-json

Once done, you can check the php version using.

$ php-v

The output looks like.

Now, we configure the php file.

$ vim /etc/php/8.0/fpm/php.ini

$ vim /etc/php/8.0/cli/php.ini

Next, add the following lines in the php config file under the [date] section.

; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Etc/UTC

This ensures there are no inconsistencies in the time zones of various files we have downloaded so far.

Once done, restart php fpm using.

$ systemctl restart php*-fpm.service

Once done, we can finally start with the downloading of LibreNMS. This requires installing git using.

$ apt install git

And add user

$ useradd -r -M -d /opt/librenms librenms

$ getent passwd librenms

next, we add a user to www-data

$ usermod -a -G librenms www-data

Once done, we update the system again and install the packages shown below.

$ apt-get update

$ apt install rrdtool whois fping imagemagick graphviz mtr-tiny nmap python3 python3-pip python3-mysqldb snmp snmpd python3-memcache mtr-tiny composer acl unzip python3-pymysql python3-dotenv python3-redis python3-setuptools python3-systemd

Now download LibreNMS using.

$ git clone https://github.com/librenms/librenms.git librenms

and output is.

Having done that, we move downloaded add-ons to /opt directory and configure snmpd

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

$ vim /etc/snmp/snmpd.conf

And now add a community string as shown below.

$ com2sec readonly default LibreNMS

Next, download the distro and restart snmpd.

$ curl -o distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro

$ chmod +x distro

$ mv distro /usr/bin/distro

And configure php-FPM after restarting it

$ cp /etc/php/8.0/fpm/pool.d/www.conf /etc/php/8.0/fpm/pool.d/librenms.conf

We now open the config file for LibreNMS.

$ vim /etc/php/8.2/fpm/pool.d/librenms.conf

And add the lines as shown:

Change [www] to [librenms]
Change user and group to “librenms”
listen = /run/php-fpm-librenms.sock

The output should look like this.

CronJob is created in the next step and the file is copied.

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

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

Net we provide certain permissions to run the Librenms command

$ 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/su - librenms
./scripts/composer_wrapper.php install --no-dev

The output looks as shown below.

Next, we enable the command of lnms and configure the apache2; we will also add the following lines.

Enable lnms:

$ ln -s /opt/librenms/lnms /usr/bin/lnms

$ cp /opt/librenms/misc/lnms-completion.bash /etc/bash_completion.d/

Apache2 config:

$ vim /etc/apache2/sites-available/librenms.conf

Addition lines:

<VirtualHost *:80>
DocumentRoot /opt/librenms/html/
ServerName librenms.example.com
AllowEncodedSlashes NoDecode
<Directory "/opt/librenms/html/">
Require all granted
AllowOverride All
Options FollowSymLinks MultiViews
# Enable http authorization headers
<IfModule setenvif_module>
SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
<FilesMatch ".+\.php$">
SetHandler "proxy:unix:/run/php-fpm-librenms.sock|fcgi://localhost"

Following is the final step required to run and start NMS.

Disabling the file: 000-default and running rewrite command

$ a2dissite 000-default

$ a2enmod proxy_fcgi setenvif rewrite

Enabling the new configuration file.

$ a2ensite librenms.conf

Restart the php-fpm and apachhe2

$ systemctl restart php8.0-fpm

$ systemctl restart apache2

Now we can successfully access the LibreNMS interfacing.


And we can see all required files are installed.

Next, we provide the asked credentials and make a user before accessing LibreNMS.

Afterwards, you’ll have to click on the ‘Build Database’ button.

Now, log in using the credentials you used before.


In this article, we went over the process of installing the Libre Network Monitoring System. This tool helps overlook the status of your devices and ensures you are up to date regarding the stats of the device under observation. We hope any confusion you faced regarding the installation of LibreNMS on Your Linux system has subsided after going through this article.

About the author

Zeeman Memon

Hi there! I'm a Software Engineer who loves to write about tech. You can reach out to me on LinkedIn.