This tutorial intends to teach you to Install and Configure LibreNMS on Ubuntu 22.04.
LibreNMS is a powerful open-source network monitoring solution that can be used to monitor devices and services on your network. It offers various features, including support for multiple protocols, performance monitoring, alerts, and more. LibreNMS is easy to install and configure, and it can be used on a variety of platforms.
Steps To Install and Configure LibreNMS on Ubuntu 22.04
To complete this guide, you must log in to your server as a non-root user with sudo privileges. To do this, you can follow this guide on Initial Server Setup with Ubuntu 22.04.
Install MariaDB on Ubuntu 22.04
First, update your local package index with the following command:
sudo apt update
Then, use the following command to install MariaDB on Ubuntu 22.04:
sudo apt install mariadb-server -y
When your installation is completed, secure your MariaDB by running the script below and setting a root password for it:
When you are done, you need to edit your MariaDB configuration file.
Open the file with your favorite text editor, here we use vi:
sudo vi /etc/mysql/mariadb.conf.d/50-server.cnf
Find the [mysqld] section and add the following lines in the section:
When you are done, save and close the file.
Now restart your MariaDB service with the command below to apply the changes:
sudo systemctl restart mariadb
Create a Database for LibreNMS
At this point, you need to create a database and user for the LibreNMS on Ubuntu 22.04.
First, log in to your MariaDB shell with the following command:
sudo mysql -u root -p
From your MariaDB shell, you need to create a database for your LibreNMS. Here we named it librenms you can replace it with your desired name.
MariaDB [(none)]> CREATE DATABASE librenms CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Also, you need to create a user for your LibreNMS database. Here we named it orca you can choose your own name.
Remember to replace the password with a strong password.
MariaDB [(none)]> CREATE USER 'orca'@'localhost' IDENTIFIED BY 'securepassword';
Here you need to grant all the privileges to the LibreNMS database with the command below:
MariaDB [(none)]> GRANT ALL PRIVILEGES ON librenms.* TO 'orca'@'localhost';
Then, flush the privileges and exit from your MariaDB console:
MariaDB [(none)]> FLUSH PRIVILEGES; MariaDB [(none)]> EXIT;
Install Nginx and PHP on Ubuntu 22.04
LibreNMS installation on Ubuntu 22.04, requires an Nginx web server, and PHP, and some dependencies too.
To install them on Ubuntu 22.04, you can run the following command:
sudo apt install nginx-full nmap php-cli php-curl php-fpm php-gd php-json php-mbstring php-mysql php-snmp php-xml php-zip python3-dotenv python3-pip python3-pymysql python3-redis python3-setuptools python3-systemd rrdtool snmp snmpd whois acl curl composer fping git graphviz imagemagick mtr-tiny
Configure php.ini File
When your packages are installed, you need to edit the php.ini file to set your time zone on Ubuntu 22.04.
Open the files below with your favorite text editor, here we use vi:
# sudo vi /etc/php/8.1/fpm/php.ini # sudo vi /etc/php/8.1/cli/php.ini
Find the date.timzone line and uncomment it by removing the “;” from the beginning of the line and setting it to UTC:
date.timezone = UTC
When you are done, save and close the files.
Set up LibreNMS on Ubuntu 22.04
First of all, you need to create a user for LibreNMS on Ubuntu 22.04 with the command below:
sudo useradd librenms -d /opt/librenms -M -r -s /bin/bash
Then, add the LibreNMS user to the www-data group with the following command:
sudo usermod -a -G librenms www-data
Now you can download the latest version of LibreNMS from Git to the /opt directory with the command below:
sudo git clone https://github.com/librenms/librenms.git /opt/librenms
Next, create a log file for LibreNMS with the following command:
sudo touch /opt/librenms/logs/librenms.log
Then, copy the SNMP sample configuration file with the following command:
sudo cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf
Next, edit the snmpd.conf file:
sudo vi /etc/snmp/snmpd.conf
Find the following line:
com2sec readonly default RANDOMSTRINGGOESHERE
And, replaced it with the following line:
com2sec readonly default mysnmpserverkey
Save and close the file.
Then, download the SNMP distro binary and copy it to your desired location:
# sudo curl -o distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro # sudo chmod +x distro # sudo mv distro /usr/bin/distro
Next, restart the SNMP service to apply the changes:
sudo systemctl restart snmpd
Next, you will also need to copy LibreNMS cron and logrotate file to the desired location on Ubuntu 22.04. You can copy them with the following command:
#sudo cp /opt/librenms/librenms.nonroot.cron /etc/cron.d/librenms #sudo cp /opt/librenms/misc/librenms.logrotate /etc/logrotate.d/librenms
Next, change the directory to the librenms and install required dependencies using the following command:
# cd /opt/librenms # ./scripts/composer_wrapper.php install --no-dev
Once all the dependencies are installed, change the ownership of the librenms directory and give necessary permissions with the following command:
# chown -R www-data:librenms /opt/librenms # chmod -R 775 /opt/librenms # setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/ # setfacl -R -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
Once you are finished, you can proceed to the next step.
Configure Nginx as a reverse proxy for LibreNMS
At this point, you need to set Nginx as a reverse proxy for LibreNMS. You need to create a virtual host file for Librenms on Ubuntu 22.04 with the command below:
sudo vi /etc/nginx/conf.d/librenms.conf
Add the following contents to the file:
Remember to replace the domain name with your own.
When you are done, save and close the file.
Restart Nginx to apply the changes:
sudo systemctl restart nginx php8.1-fpm
Access LibreNMS Web Interface
At this point, you can access the LibreNMS web installation by typing your domain name in your web browser:
You will see the pre-installation of LibreNMS on Ubuntu 22.04, make sure that all checks are successful then, click on the database icon.
In the Database screen, enter your database credentials and click on the check credentials.
Once it’s successful, you should see the following page, click on the Build Database button.
Then, you will see the following screen, you need to click on the key icon.
Now provide your admin username, email, and password, and click on the Add User button.
Next, click on the Finish installation button.
Next, click on “validate your install”.
You should see the LibreNMS login page. Provide your LibreNMS admin username, and password, and click on the Login button.
Now you will see your LibreNMS dashboard on Ubuntu 22.04.
That’s it, you are done.
At this point, you have learned to Install and Configure LibreNMS on Ubuntu 22.04.
Hope you enjoy it.
You may be like these articles:
2 ways To Install Android Studio on Ubuntu 20.04