In this tutorial, we will show you how to install LibreNMS on Debian 11. For those of you who didn’t know, LibreNMS is an auto discovering PHP/MySQL-based network monitoring system that includes support for a wide range of network hardware and operating systems including Cisco, Linux, FreeBSD, Juniper, Brocade, HP, and many more.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of the LibreNMS network monitoring system on a Debian 11 (Bullseye).
Prerequisites
- A server running one of the following operating systems: Debian 11 (Bullseye).
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install LibreNMS on Debian 11 Bullseye
Step 1. Before we install any software, it’s important to make sure your system is up to date by running the following apt
commands in the terminal:
sudo apt update sudo apt upgrade sudo apt install acl curl composer fping git graphviz imagemagick mtr-tiny python3-dotenv python3-pymysql python3-redis python3-setuptools python3-systemd rrdtool snmp snmpd whois
Step 2. Installing the LAMP stack.
A Debian 11 LEMP server is required. If you do not have LAMP installed, Please read our previous tutorial to install LEMP Server on Debian 11.
Step 3. Create a user account for LibreNMS.
Now we add the LibreNMS user:
sudo useradd librenms -d /opt/librenms -M -r -s /bin/bash
Step 4. Installing LibreNMS on Debian 11.
Now we clone the LibreNMS repository to /opt
directory using git
command:
cd /opt sudo git clone https://github.com/librenms/librenms.git librenms
We will need to change some folder permissions:
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/cache/ /opt/librenms/storage/
Step 5. Installing PHP dependencies.
Run the commands below to install all dependencies required by PHP on your Debian system:
sudo -u librenms bash ./scripts/composer_wrapper.php install --no-dev exit
Step 6. Configuring MariaDB.
By default, MariaDB is not hardened. You can secure MariaDB using the mysql_secure_installation
script. You should read and below each step carefully which will set the root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MariaDB:
mysql_secure_installation
Configure it like this:
- 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
Next, we will need to log in to the MariaDB console and create a database for LibreNMS. Run the following command:
mysql -u root -p
This will prompt you for a password, so enter your MariaDB root password and hit Enter. Once you are logged in to your database server, you need to create a database for LibreNMS installation:
MariaDB [(none)]> CREATE DATABASE librenms_db; MariaDB [(none)]> CREATE USER 'librenms_user'@'localhost' IDENTIFIED BY 'your-strong-password'; MariaDB [(none)]> GRANT ALL PRIVILEGES ON librenms_db.* to librenms_user@'localhost'; MariaDB [(none)]> FLUSH PRIVILEGES; MariaDB [(none)]> exit
After that, edit MariaDB’s configuration:
echo 'innodb_file_per_table=1' >> /etc/mysql/mariadb.conf.d/50-server.cnf echo 'lower_case_table_names=0' >> /etc/mysql/mariadb.conf.d/50-server.cnf
Step 7. Configure Nginx.
Create an Nginx virtual host file for LibreNMS installation:
sudo nano /etc/nginx/sites-enabled/librenms.vhost
Add the following file:
server {
listen 80;
server_name librenms.your-domain.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;
}
}
Save and close the file, then restart the Nginx web server so that the changes take place:
sudo systemctl restart nginx
Next, enable command auto-completion for LibreNMS:
sudo ln -s /opt/librenms/lnms /usr/bin/lnms sudo cp /opt/librenms/misc/lnms-completion.bash /etc/bash_completion.d/
After that, copy the cron job information to enable automatic discovery and copy the logrotate configuration file to rotate the old logs:
sudo cp /opt/librenms/librenms.nonroot.cron /etc/cron.d/librenms sudo cp /opt/librenms/misc/librenms.logrotate /etc/logrotate.d/librenms
Step 8. Accessing the LibreNMS Web Interface.
Once successfully installed, open a web browser and go to http://librenms.your-domain.com
and you will see the following screen:
Congratulations! You have successfully installed LibreNMS. Thanks for using this tutorial for installing the latest version of LibreNMS network monitoring system on Debian 11 Bullseye. For additional help or useful information, we recommend you check the official LibreNMS website.