Installing LibreNMS on Debian Latest

Introduction

LibreNMS is a powerful and flexible network monitoring system that can be used to monitor various network devices, including routers, switches, servers, and more. In this tutorial, we will go through the steps to install LibreNMS on Debian latest.

Prerequisites

Before we proceed, ensure that you have the following prerequisites:

Step 1: Install Required Dependencies

To install LibreNMS on Debian latest, we must first install some of the required dependencies including PHP and its extensions, composer, and some other packages.

First, update your system's package list and install the required dependencies by running the commands below:

sudo apt update
sudo apt install -y composer fping git python-memcache python-mysqldb python3-memcache python3-mysqldb rrdtool snmp snmpd whois curl acl

Step 2: Install SNMP and SNMPD

SNMP is the protocol used by LibreNMS to gather network metrics. Therefore, we need to install the SNMP daemon on the Debian latest server.

Install SNMP and SNMPD using the following command:

sudo apt-get install -y snmp snmpd

Step 3: Create a Database

Next, we need to create a new database for LibreNMS to use. Login to your MySQL server:

sudo mysql -u root -p

Create a new user and database for LibreNMS:

mysql> CREATE USER 'librenms'@'localhost' IDENTIFIED BY 'PASSWORD';
mysql> CREATE DATABASE librenms CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
mysql> GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'localhost' IDENTIFIED BY 'PASSWORD';
mysql> flush privileges;
mysql> exit;

Step 4: Download and Install LibreNMS

Now, we can download and install LibreNMS. We will download the latest stable version from their GitHub repository:

sudo mkdir -p /opt/librenms && sudo chown -R www-data:www-data /opt/librenms
sudo git clone https://github.com/librenms/librenms.git /opt/librenms
cd /opt/librenms
sudo composer install --no-dev
sudo cp .env.example .env
sudo php /opt/librenms/build/snmpd.php

Step 5: Configure LibreNMS

In this step, we will configure LibreNMS.

Open the .env file using a text editor:

sudo nano /opt/librenms/.env

Update the following variables with your respective values:

APP_KEY=SomeRandomString
DB_HOST=localhost
DB_NAME=librenms
DB_USER=librenms
DB_PASS= PASSWORD

Save the changes and close the file.

Now, set the correct permissions to the LibreNMS directory:

sudo chown -R librenms:librenms /opt/librenms

Finally, run the following command to finalize the installation:

sudo /opt/librenms/daily.sh

The script will set up the necessary cron job for LibreNMS.

Step 6: Configure Web Server

For our final step, we need to configure the webserver to serve the LibreNMS application.

Apache Configuration:

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

Add the following configuration to the file:

<VirtualHost *:80>
ServerName librenms.example.com

DocumentRoot /opt/librenms/html/
<Directory /opt/librenms/html/>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>

ErrorLog /var/log/apache2/librenms-error.log
CustomLog /var/log/apache2/librenms-access.log combined

</VirtualHost>

Save the file and exit the text editor.

Then, enable the site and restart Apache service:

sudo a2ensite librenms.conf
sudo systemctl restart apache2

nginx Configuration:

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

Add the following configuration to the file:

server {
    listen 80;
    server_name librenms.example.com;

    root /opt/librenms/html;
    index index.php;

    access_log /var/log/nginx/librenms.access.log;
    error_log /var/log/nginx/librenms.error.log;

    location / {
        try_files $uri /index.php?$query_string;
    }

    location ~ \.php$ {
        fastcgi_pass unix:/run/php/php8.0-fpm.sock;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param LIBRENMS_USER librenms;
        fastcgi_param LIBRENMS_GROUP librenms;
    }
}

Save the file and exit the text editor.

Finally, enable the site and restart nginx service:

sudo ln -s /etc/nginx/sites-available/librenms.conf /etc/nginx/sites-enabled/
sudo systemctl restart nginx

Conclusion

We have successfully installed and configured LibreNMS on Debian latest. You can now access the LibreNMS application by navigating to http:/// in your web browser. To log in, use the default username "admin" and the password "admin". You should change this password immediately after logging in.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!