This article is intended to teach you how to install LibreNMS on Debian 9.
For any system administrator it is essential to monitor the network it manages. At the same time, it is very important to have the right tool to do that task.
LibreNMS is a tool with a web interface for monitoring services within a network. It is released under GPLV3, so it is open source. It includes support for a wide range of network hardware and operating systems including Cisco, Linux, FreeBSD, Juniper, Brocade, Foundry, HP and many more.
You can install it in the main Linux distributions oriented to it, for example, Debian, Ubuntu Server, CentOS, Suse and RHEL. It requires a web server, PHP and a database manager like MariaDB.
0.- What you need
Installing LibreNMS is not as complicated as it may seem, but the following must be taken into account:
- It is necessary to have knowledge about the Linux terminal.
- You must be able to access through ssh.
- Commands must be run as root user. So your user must be able to have that privilege.
Let’s get to work.
1.- Upgrade the system
It’s always a good idea to have your operating system updated when you start an installation like this one. With this you will have the latest security patches on your system and it will be safer.
:~$ su :~# apt update && apt upgrade
And with this it’s done.
2.- Install Apache Web server
The second step to install LibreNMS in Debian is to install a web server. In this case, I will use Apache Web server.
:~# apt install apache2
Then enable the service to start with the system.
:~# systemctl enable apache2
Finally, go to your web browser and access from the IP address of the server.
If you see the image above, apache web server is correctly installed.
2. Install PHP
In order to run LibreNMS you need to install PHP.
:~# apt install php7.0-cli php7.0-curl php7.0-mbstring php7.0-gd libapache2-mod-php7.0 php7.0-snmp php7.0-xml php7.0-mysql php7.0-zip php7.0-json
At the end of the installation, you must test the installation. Create a file in
/var/www/html/ and put some simple PHP code like this.
:~# nano /var/www/html/test.php
<?php echo "PHP IS WORKING"; ?>
Now, try open it from the browser.
If the code works then PHP is correctly installed.
3. Install MariaDB
In order to continue installing LibreNMS you have to install MariaDB. LibreNMS requires a database manager and MariaDB is simple, powerful and free.
:~# apt install mariadb-server
Now start, and enable the MariaDB service.
:~# systemctl enable mariadb :~# systemctl start mariadb
Now you have to configure MariaDB. So, run the
mysql_secure_installation script. There you will be able to define the password and other things.
After defining the password, you will be asked other questions. Answer as you like, I did it Y, N, Y, Y.
The next step to install LibreMNS in Debian 9 is to create a database dedicated to the tool. It is also necessary to create a new user and assign necessary permissions.
:~# mysql -u root -p
CREATE DATABASE librenms; USE librenms; GRANT ALL PRIVILEGES ON librenms.* TO 'librenmsuser'@'localhost' IDENTIFIED BY 'librenmspss'; FLUSH PRIVILEGES; exit;
Obviously, it replaces the data with what you consider appropriate. Choose a secure password.
Finally, edit the file /etc/mysql/mariadb.conf.d/50-server.cnf and leave it as in the image. You just nedd to add the following in mysqld section.
:~# nano /etc/mysql/mariadb.conf.d/50-server.cnf
innodb_file_per_table=1 sql-mode="" lower_case_table_names=0
Then, restart the service:
:~# systemctl restart mariadb
MariaDB is done.
4. Install some required packages
In order for the installation to be ideally achieved, it is necessary to install some extra packages. Run:
:~# apt install composer fping git graphviz imagemagick mtr-tiny nmap python-memcache python-mysqldb rrdtool snmp snmpd whois
5. Install LibreNMS
Now it is the turn to install LibreNMS. First, create a system user with home located at
:~# useradd librenms -d /opt/librenms -M -r :~# usermod -a -G librenms www-data
You can now download LibreNMS cloning its repository thanks to Git.
:~# cd /opt/ :~# git clone https://github.com/librenms/librenms.git librenms
Now, change the owner of the folder.
:~# chown -R librenms:librenms /opt/librenms
It is now necessary to copy the initial configuration file.
:~# cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf
Replace RANDOMSTRINGGOESHERE line and set your own.
:~# nano /etc/snmp/snmpd.conf
Then, you must download a distro detection script.
:~# curl -o /usr/bin/distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro
The next thing is to make the script executable and then restart the snmpd service.
:~# chmod +x /usr/bin/distro :~# systemctl restart snmpd
Next, copy the cron script provided by LibreNMS to the
:~# cp /opt/librenms/librenms.nonroot.cron /etc/cron.d/librenms
And finally, Copy the logrotate script too.
:~# cp /opt/librenms/misc/librenms.logrotate /etc/logrotate.d/librenms
Next, move the folder from
:~# mv librenms/ /var/www/html/
:~# cd /var/www/html/libremns :~# ./scripts/composer_wrapper.php install --no-dev
6. Access from the web browser
Now you must complete the installation from the web. Go to
You will see this:
Now enter the parameters of the database you configured previously.
Then, it will start the configuration of the database. If you don’t see any errors, you can continue.
Now you have to configure your username and password.
If all goes well, you’ll see this. Click on generate config.
After creating the whole process. You access the log in screen.
This type of tool is of great help to system administrators. LibreNMS is easy to install but you have to have a certain level of knowledge.
Spread this article on your social networks.