How to Install LibreNMS on Debian 11 Bullseye

Tutorial to learn LibreNMS installation steps and commands on Debian 11 Bullseye or Debian 10 Buster Linux using command terminal to monitor network devices.

Monitoring network environments becomes increasingly demanding as complexity increases. Powerful systems like LibreNMS usually provide solid basic functionality, but they are often overwhelmed with special tasks like monitoring or backing up configurations. LibreNMS has long included RANCID (Really Awesome New Cisco Config Differ), which specializes in monitoring Cisco router configurations. Using a simple routing table in which login data is stored, the tool accesses configuration settings and can notify the administrator of any changes via email.

LibreNMS is an open-source network monitoring system that can also graphically process determined network data. Moreover, the tool has a warning system which can also be used with other tools. LibreNMS can be controlled with apps via Android and iPhone.

Some key features:

Auto Discovery
Customizable alert
API access
The billing system
Automatic updates
Distributed survey
Offers smartphone apps for Android and iOS
Based on MySQL and PHP

Steps to Install LibreNMS on Debian 11 Bullseye

1. Requirements

To perform this tutorial to configure LibreNMS on your Debian Linux, the user needs a web server – Nginx or apache. Here we are using Apache. With PHP and MariaDB. Also, the user must have a system user with sudo access to install new packages.

2. Install web server on Debian 11

We can use Apache or Nginx web server, to install LibreNMS you can use any of them. Here is Apache’s usage, hence the corresponding command:

sudo apt install apache2

Start the web server services:

sudo systemctl enable --now apache2

3. Install PHP, MariaDB and dependencies

Here we will install PHP, MariaDB and other required packages to easily configure LibreNMS on Debian 11 or 10. To install all of them, we can use the given command:

sudo apt install acl curl nano composer fping git graphviz imagemagick mariadb-client mariadb-server mtr-tiny nginx-full nmap php-cli php-curl php-fpm php-gd php-gmp php-json php-mbstring php-mysqli php-snmp php-xml php-zip rrdtool snmp snmpd whois unzip python3-pymysql python3-dotenv python3-redis python3-setuptools python3-systemd python3-pip

4. Configure MariaDB for LibreNMS

Before creating a database, let’s configure MariaDB for LibreNMS, so edit the database server configuration file.

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

Under [mysqld] add the following lines:

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

Save the file by pressing CTRL+Otype Yesand use CTRL+X to leave.

Restart the database service:

sudo systemctl restart mariadb

And enable the same:

sudo systemctl enable mariadb

Secure your MariaDB:

sudo mysql_secure_installation

Follow the guided wizard, create a password for the database root user, delete the demo database, and disallow remote login and anonymous users.

5. Log in and create a database

Now, let’s create dedicated software to store the data generated by the LibreNMS.

sudo mysql

Use the commands to create a database.

Here we use the database name- librenms, use whatever you want to use. Don’t forget to replace the password with what you want to define.

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

Set time zone for PHP:

sudo sed -i "s,;date.timezone =,date.timezone = "Europe/Amsterdam",g" /etc/php/*/apache2/php.ini
sudo sed -i "s,;date.timezone =,date.timezone = "Europe/Amsterdam",g" /etc/php/*/cli/php.ini
sudo sed -i "s,;date.timezone =,date.timezone = "Europe/Amsterdam",g" /etc/php/*/fpm/php.ini

To note: Change the Europe/Amsterdam depending on your country. If you don’t know the PHP value of your time zone, refer to the Official page intended for this.

Also change the system time zone accordingly:

sudo timedatectl set-timezone Europe/Amsterdam
sudo dpkg-reconfigure -f noninteractive tzdata
sudo mysql -uroot --execute="SET GLOBAL time_zone="Europe/Amsterdam";"
sudo systemctl restart apache2 mariadb

6. Download LibreNMS on Debian 11

The LibreNMS files are not present for download using Debian’s repository, so let’s clone them using Git directly from its Github repository.

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

7. Add a Librenms user

Let’s create a dedicated user who can only access the

sudo useradd librenms -d /opt/librenms -M -r -s /bin/bash

Also add the LibreNMS user to the Apache group

usermod -a -G librenms www-data

Set permissions for uploaded files:

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

Install PHP dependencies

Switch to the user created by LibreNMS, then install the PHP dependencies required by this network monitoring platform.

sudo -u librenms bash
./scripts/composer_wrapper.php install --no-dev
exit

8. Configure PHP-FPM for LibreNMS installation

Create the PHP FPM configuration file for LibreNMS by copying the existing configuration file:

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

Now edit the copied file

sudo nano librenms.conf

To replace [www] for [librenms]

Change the user and group of data-www to librenms

user = librenms
group = librenms

Update Listen with a single name

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

Save the file – CTRL+Ohurry Yes and exit- CTRL+X.

Go back to your root directory.

cd

Configure snmpd

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

Change RANDOMSTRINGGOESICI for LibreNMS and save the file.

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

Create a Cron job

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

9. Create the Apache virtual host configuration file

To access the LibreNMS web interface, we need to tell our Apache server where its files are. For this, we create a virtual host configuration file:

sudo nano /etc/apache2/sites-available/librenms.conf

Add the following lines:


DocumentRoot /opt/librenms/html/
ServerName 192.168.0.17
AllowEncodedSlashes NoDecode

Require all granted
AllowOverride All
Options FollowSymLinks MultiViews

# Enable http authorization headers

SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1


SetHandler "proxy:unix:/run/php-fpm-librenms.sock|fcgi://localhost"

Save the file by pressing Ctrl + O, Y and Ctrl + X to exit.

To note: Replace the server name with your IP address or FQDN such as librenms.example.com

Disable the default site and enable the one you just created

sudo a2dissite 000-default
sudo a2enmod proxy_fcgi setenvif rewrite
sudo a2ensite librenms.conf

Restart the services:

sudo systemctl restart apache2
sudo systemctl restart php*-fpm

10. LibreNMS Web Interface

Once the LibreNMS setup is complete, go to your system browser and point it to the server IP address or domain name you used.

for example- http://server-ip-address

First, the installation setup will check the dependencies required by the software.

After that, add your MariaDB database, username and password. Once done, check if LibreNMS is able to connect to the database or not. If so, click the “Create database” button.

LibreNMS database

Create an administrator user.

Create an administrator user

Log in to the LibreNMS backend.

LibreNMS Login

Install LibreNMS on Debian 11 Bullseye

Other Items:

Install Fotoxx Image Editor on Debian 11 Bullseye
How to install Telegram on Debian 11 Bullseye
Install Jupyter Notebook on Debian 11 Bullseye Linux
How to install Cacti Overseer Debian 11 Bullseye