17.6 C
Texas
angeloma
Senior Writer and partner

How to install LibreNMS on Debian 9?

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.

- Advertisement -

Let’s start.

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

1.- Upgrading the system
1.- Upgrading the system

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

2.- Installing apache2
2.- Installing 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. http://IP_SERVER

3.- Apache default page on Debian 9
3.- Apache default page on Debian 9

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

4.- Installing PHP
4.- Installing PHP

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";
?>

5.- Testing PHP
5.- Testing PHP

Now, try open it from the browser.

6.- PHP is installed
6.- PHP is installed

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

7.- Installing MariaDB
7.- Installing MariaDB

Now start, and enable the MariaDB service.

:~# systemctl enable mariadb
:~# systemctl start mariadb

8.- Enabling the MariaDB service
8.- Enabling the MariaDB service

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.

:~# mysql_secure_installation

9.- Running the mysql_secure_installation
9.- Running the mysql_secure_installation

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;

10.- Creating the new database for Librenms
10.- Creating the new database for Librenms

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

11.- Editing the mariadb configuration file
11.- Editing the mariadb configuration file

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

12.- Installing some required packages
12.- Installing some required packages

5. Install LibreNMS

Now it is the turn to install LibreNMS. First, create a system user with home located at /opt/librenms

:~# useradd librenms -d /opt/librenms -M -r
:~# usermod -a -G librenms www-data

13.- Creating a new system user
13.- Creating a new system user

You can now download LibreNMS cloning its repository thanks to Git.

:~# cd /opt/
:~# git clone https://github.com/librenms/librenms.git librenms

14.- Cloning the LibreNMS repository
14.- Cloning the LibreNMS repository

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

15.- Configuring LibreNMS
15.- Configuring LibreNMS

Replace RANDOMSTRINGGOESHERE line and set your own.

:~# nano /etc/snmp/snmpd.conf

16.- Replacing the ramdom string
16.- Replacing the random string

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

17.- Downloading the distro script
17.- Downloading the distro script:

Next, copy the cron script provided by LibreNMS to the /ect/cron.d directory.

:~# 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

18.- Copying the script
18.- Copying the script

Next, move the folder from /opt/ to /var/www/html

:~# mv librenms/ /var/www/html/

Finally run:

:~# cd /var/www/html/libremns
:~# ./scripts/composer_wrapper.php install --no-dev

19.- Running composer
19.- Running composer

6. Access from the web browser

Now you must complete the installation from the web. Go to http://IP_SERVER/libremns/html/

You will see this:

20.- Completing the Librenms Installation
20.- Completing the Librenms Installation

Now enter the parameters of the database you configured previously.

21.- Setting the Database Parameters
21.- Setting the Database Parameters

Then, it will start the configuration of the database. If you don’t see any errors, you can continue.

22.- Database without errors
22.- Database without errors

Now you have to configure your username and password.

23.- Creating the new user
23.- Creating the new user

If all goes well, you’ll see this. Click on generate config.

24.- User created
24.- User created

After creating the whole process. You access the log in screen. http://IP_SERVER/librenms/html/index.php/login

25.- LibreNMS log in screen
25.- LibreNMS log in screen

That’s it.

Conclusion

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.

 

 

 

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

4 COMMENTS

  1. I cannot make it work. There are a couple of mistakes. You need zip & curl too. At the end of point 5 you spelled libremns and it is librenms.

    Then at point 6 it shows an error:
    ***********************************************************************
    Whoops, the web server could not write required files to the filesystem.
    Running the following commands will fix the issue most of the time:

    sudo chown -R librenms:librenms /var/www/html/librenms

    sudo setfacl -d -m g::rwx /var/www/html/librenms/bootstrap/cache /var/www/html/librenms/storage /var/www/html/librenms/logs /var/www/html/librenms/rrd

    sudo chmod -R ug=rwX /var/www/html/librenms/bootstrap/cache /var/www/html/librenms/storage /var/www/html/librenms/logs /var/www/html/librenms/rrd

    usermod -a -G librenms www-data

    If using SELinux you may also need:

    semanage fcontext -a -t httpd_sys_rw_content_t ‘/var/www/html/librenms/bootstrap/cache(/.*)?’

    semanage fcontext -a -t httpd_sys_rw_content_t ‘/var/www/html/librenms/storage(/.*)?’

    semanage fcontext -a -t httpd_sys_rw_content_t ‘/var/www/html/librenms/logs(/.*)?’

    semanage fcontext -a -t httpd_sys_rw_content_t ‘/var/www/html/librenms/rrd(/.*)?’

    restorecon -RFv /var/www/html/librenms

    *************************************************************************

    Tried first solution, setfacl command not found. Stopped here.

  2. on step 16, first install curl -> apt install curl

    on step 18, install php7.3
    – apt install ca-certificates apt-transport-https
    – wget -q https://packages.sury.org/php/apt.gpg -O- | apt-key add –
    – echo “deb https://packages.sury.org/php/ stretch main” | tee /etc/apt/sources.list.d/php.list
    – apt install php7.2
    – apt install php7.2-cli php7.2-common php7.2-curl php7.2-mbstring php7.2-mysql php7.2-xml php7.2-gd php7.2-zip
    – install acl -> apt install acl, and then : ./scripts/composer_wrapper.php install –no-dev

    CAN’T INSTALL COMPOSER T-T

  3. Dear, the article is very useful, congratulations. But when I execute:
    # ./scripts/composer_wrapper.php install –no-dev
    I get the following errors:
    Problem 1
    – This package requires php ^7.1.3 but your HHVM version does not satisfy that requirement.
    Problem 2
    – Installation request for doctrine/cache v1.8.0 -> satisfiable by doctrine/cache[v1.8.0].
    – doctrine/cache v1.8.0 requires php ~7.1 -> your PHP version (7.0.33) does not satisfy that requirement.
    Problem 3
    – Installation request for doctrine/dbal v2.9.2 -> satisfiable by doctrine/dbal[v2.9.2].
    – doctrine/dbal v2.9.2 requires php ^7.1 -> your PHP version (7.0.33) does not satisfy that requirement.
    Problem 4
    – Installation request for doctrine/event-manager v1.0.0 -> satisfiable by doctrine/event-manager[v1.0.0].
    – doctrine/event-manager v1.0.0 requires php ^7.1 -> your PHP version (7.0.33) does not satisfy that requirement.
    Problem 5
    – Installation request for doctrine/inflector v1.3.0 -> satisfiable by doctrine/inflector[v1.3.0].
    – doctrine/inflector v1.3.0 requires php ^7.1 -> your PHP version (7.0.33) does not satisfy that requirement.
    Problem 6
    – Installation request for laravel/framework v5.7.28 -> satisfiable by laravel/framework[v5.7.28].
    – laravel/framework v5.7.28 requires php ^7.1.3 -> your PHP version (7.0.33) does not satisfy that requirement.
    Problem 7
    – Installation request for laravel/laravel v5.7.28 -> satisfiable by laravel/laravel[v5.7.28].
    – laravel/laravel v5.7.28 requires php ^7.1.3 -> your PHP version (7.0.33) does not satisfy that requirement.
    Problem 8

    The PHP you’ve isntalled is 7.0 but from this script 7.1.3 version is required.
    Please can you help me?
    Thanks a lot.

  4. “apt -y install acl” will solve Your problem

    Current version, require at least php 7.1.3. You should update instruction, with info, about how to install it.

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article