Enter your email address below and subscribe to our newsletter

How to Install LibreNMS on Ubuntu 20.04

Share your love

LibreNMS is a popular community-based tool that discovers all the available networks automatically. LibreNMS is a network monitoring tool that is based on PHP, MySQL, and SNMP. 

It includes a wide range of network hardware support and Operating Systems support including Cisco, Linux, FreeBSD, Juniper, Brocade, Foundry, HP, and many more. In this guide, we are going to cover how you can install LibreNMS on Ubuntu with configuration.

Key Features of LibreNMS

  • Auto-discovery: LibreNMS will automatically identify available networks by using CDP (Cisco Discovery Protocol), LLDP (Link Layer Discovery Protocol), OSPF (Open Shortest Path First), BGP (Border Gateway Protocol), SNMP (Simple Network Management Protocol), and ARP (Address Resolution Protocol).
  • Flexible Alerts: You can customize the way you want alerts such as via email, IRC slack, and more.
  • Secure Updates: It will automatically fetch, download and install updates without any intervention of the user which includes security patches, and new versions.
  • Android and iOS Support: You get a native Android and iOS app that provides core functionalities.

Installing LibreNMS on Ubuntu

In this process, we are going to install LibreNMS with its other essential requirements such as NGINX, PHP, and MariaDB. So let’s start our step-by-step guide with system updation.

Step 1: Updating System Repositories

As we are going to download many tools, it is essential for us that we get the most recent and stable version of each of them. We can achieve it by updating our system and downloading updates (if any.). Utilize the following command for updating your system:

sudo apt update && sudo apt upgrade -y


1. sudo apt update _ sudo apt upgrade -y

Step 2: Installing NGINX 

NGINX is a highly efficient web server that is also getting positive reviews from new users. NGINX can also be used as a reverse proxy. Run the following command to install NGINX:

sudo apt install nginx -y


2. sudo apt install nginx -y

Step 3: Starting and Checking Status of NGINX

After installing NGINX, we have to enable it to take effect by the following command:

sudo systemctl start nginx


3. sudo systemctl start nginx

To check whether it is active, use the following command to check its status:

sudo systemctl status nginx


4. sudo systemctl status nginx

Step 3: Allowing Connections of NGINX Through Firewall

If you have an active firewall, it won’t allow connections to NGINX. To access NGINX without any issues, we have to allow it to pass through the firewall by the following command:

sudo ufw allow 'Nginx Full'


5. sudo ufw allow _Nginx Full_

Now, let’s check the status of the firewall by the given command:

sudo ufw status


6. sudo ufw status

Step 4: Installing MariaDB 

MariaDB is a replacement for MySQL which is developed by former members of MySQL. They were concerned about Oracle will make MySQL a closed source. Use the following command to install MariaDB:

sudo apt install mariadb-server mariadb-client -y


7. sudo apt install mariadb-server mariadb-client -y

Step 5: Configuring MariaDB

LibreNMS is not completely compatible with MySQL so it requires some changes in the configuration file. We are going to use nano as a text editor which is easy compared to Vim. Use the following command to open the configuration file:

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


8. mariaDB config file

Once the configuration file opens, paste the following lines under [mysqld] section:


9. pasting lines in mysqld section

Use CTRL + O to save changes and CTRL + X to exit from nano.

Now, restart MariaDB by the following command to activate the changes that we made:

sudo systemctl restart mariadb

10. sudo systemctl restart mariadb

Step 5: Creating Database for LibreNMS

Once we are done with the configuration file, we are required to create a database for LibreNMS by the following command:

sudo mysql -u root


Now you will have to use the following command. But before pasting it, make sure that you change your username and password.

CREATE DATABASE librenms CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'librenms'@'localhost' IDENTIFIED BY 'StrongPassword';
GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'localhost';

11. creating databse

Step 6: Installing PHP 

To install PHP, we are not required to add separate repository because Ubuntu already has PHP by default. Use following command to install PHP:

sudo apt -y install wget php php-{pear,cgi,common,curl,mbstring,gd,mysql,bcmath,imap,json,xml,snmp,fpm,zip}


12. PHP installation

To check PHP has been installed without any error, we can check its installed version by the following command:

php -v

13. php -v

Step 7: Configuring and Starting PHP

We have to enter our current location to ensure we get the correct time. For that, we have to make changes to 2 configuration files. We are going to change those files one by one. Use the following command to open the first configuration file:

sudo nano /etc/php/*/fpm/php.ini

14. first config PHP file

This is a large file so press CTRL + W and type date. You will get there. Now, we have to enter our time zone. In our case, it is Asia/Kolkata.

15. date and time zone in 1st config file

Similarly, let’s change our second configuration file. To open it, use the given command.

sudo nano /etc/php/*/cli/php.ini

16. second configuration file

Similarly, we are required to follow the same steps that we used in the previous step to enter our timezone. Enter your timezone under the date section and save it.

After configuring both files, let’s start PHP with the following command:

sudo systemctl restart php*-fpm.service

18. sudo systemctl restart php_-fpm.service

Step 8: Installing LibreNMS With Creating New User

In this step, we are going to install LibreNMS from git. If you don’t have git installed, you can install it by the following command:

sudo apt install git -y

19. sudo apt install git -y

LibreNMS will be run by a user named librenms. But we have to create it by the following command:

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

20. adding user named librenms

getent passwd librenms

21. getent passwd librenms

Now, let’s add our newly created user to a web user group called www-data by the following command:

sudo usermod -a -G librenms www-data

22. sudo usermod -a -G librenms www-data

Let’s install the required packages by LibreNMS. Use the following command to proceed further in the installation process:

sudo 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 -y

23. required packages by LibreNMS

Clone LibreNMS by the following command:

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

24. clonning from git

We are required to move the librenms folder to /opt by given command:

sudo mv librenms/ /opt/

25. moving folder

Step 9: Configuring Snmpd 

We are required to copy the configuration template by given command:

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

26. copying configuration templates

Now, open configuration file situated at /etc/snmp/snmpd.conf by given command:

sudo nano /etc/snmp/snmpd.conf

27. snpd config file

You will have to replace your community string with text named RANDOMSTRINGGOESHERE


We have used LibreStr0ngSecret as a community string.

29. LibreStr0ngSecret

Press CTRL + O to save and CTRL + X to exit nano.

After configuring, let’s download the distro by the following command:

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

30. downloading distro

chmod +x distro

31. chmod +x distro

Now, let’s move downloaded distro to /usr/bin/ by given command:

sudo mv distro  /usr/bin/distro

32. moving distro

After all the configuration, we have to restart snmpd by the given command:

sudo systemctl restart snmpd

33. sudo systemctl restart snmpd

Step 10: Configuring PHP-FPM

We have to copy default www.conf file by given command:

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

33.1 copying file of www

Now, open the copied file for editing by given command:

sudo nano /etc/php/8.0/fpm/pool.d/librenms.conf

33.2 sudo nano

change pool name is given in bracket [www] to [librenms]

34. previous pool name

35. changed pool name to librenms

Change user and group to librenms. As shown in the image:

36. changed user and group to librenms

Change Listen as given syntax:

listen = /run/php-fpm-librenms.sock

Step 11: Creating LibreNMS Cron Job

Run the following command to set cron job for LibreNMS:

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

37. setting cron job for LibreNMS

Step 12: Copying Logrotate Config file

LibreNMS keeps all the logs stored at /opt/librenms/logs. Over it gets large and be rotated out. To rotate out old logs, you can use the given configuration file:

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

38. rotating old log files

Step 13: Fixing Permission Errors for LibreLMS

It will get errors if you try to write files and folders which has only read permission. Follow the given commands to change the permission of files and folders.

sudo chown -R librenms:librenms /opt/librenms

39. sudo chown -R librenms_librenms

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

40. sudo setfacl 1st

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

41. sudo setfacl 2nd

Now, let’s run composer install for further configuration:

sudo su – librenms

42. sudo su - librenms

you will get space for entering lines. Enter the following line of code:

./scripts/composer_wrapper.php install –no-dev

Hit Enter and type exit. It will start downloading files.

Now, enable lnms command completion by following command:

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

43. sudo ln -s

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

44. sudo cp

Step 14: Configuring NGINX

We are going to create a VirtualHost definition for NGINX which LibreNMS will use. Create a new file using the following command:

sudo nano /etc/nginx/conf.d/librenms.conf

45. NGINX final config

It will be black file, you have to enter following data after modification:

server {
listen      80;
server_name librenms.example.com;
root        /opt/librenms/html;
index       index.php;
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 ~ [^/]\.php(/|$) {
fastcgi_pass unix:/run/php-fpm-librenms.sock;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi.conf;
location ~ /\.(?!well-known).* {
deny all;

Now, let’s check if the syntax was good enough to run by the given command:

sudo nginx -t

46. sudo nginx -t

If it gives output with success, you are all good so far.

Step 15: Removing Default File and Restarting NGINX

To remove the default file, use the following command:

sudo rm /etc/nginx/sites-enabled/default

47. sudo rm default files

Now, let’s restart NGINX by the given command:

sudo systemctl restart nginx

48. sudo systemctl restart nginx

To restart PHP, use the following command:

sudo systemctl restart php8.0-fpm.service

49. sudo systemctl restart php8.0-fpm.service

That’s it, you have LibreNMS installed and configured on your system. You can access the Web interface of LibreNMS by going to  http://your-domain.com/ or  http://server-ip-address/ 

Frequently asked questions related to LibreNMS

Is LibreNMS good?

Yes, we found LibreNMS a great tool while using it. Because of its user-friendly interface, you can easily manage everything without messing up with Terminal.

Can I install LibreNMS on Windows?

No, you can’t use LibreNMS on Windows because it is not available for the Windows platform.

Related Posts:

Final words:

Installing LibreNMS on managing it on Ubuntu is easy compared to other alternatives. By combining it with PHP, NGINX, and MariaDB, you will get to experience high performance with less complexity involved.

Share your love
Sagar Sharma
Sagar Sharma

Sagar always uses Linux to its core and loves to write the technical side of system administration! While he's not writing for GeniusGeeks, you can find him writing for core linux blogs like IT'SFOSS.com and LinuxHandBook.com

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!