LibreNMS is a powerful open-source network monitoring system that provides extensive monitoring capabilities for various operating systems and network hardware. In this guide, we will walk you through the step-by-step process of installing and configuring LibreNMS on Debian 11 Bullseye. By following this guide, you will be able to set up a robust monitoring tool to efficiently manage and monitor your network infrastructure.
Prerequisites
Before we dive into the installation process, let’s make sure we have all the necessary prerequisites in place:
- Operating System: Debian 11 Bullseye
- Root privileges
Installing Packages Dependencies
To start the installation, we need to install some basic and essential packages. These packages include the LEMP stack, Python packages, snmpd, and additional system utilities. Open your terminal and follow the steps below:
- Update the Debian repositories by running the following command:
sudo apt update
- Install the required packages by executing the following command:
sudo apt install acl curl composer fping git graphviz imagemagick mariadb-client mariadb-server mtr-tiny nginx-full nmap php7.4-cli php7.4-curl php7.4-fpm php7.4-gd php7.4-gmp php7.4-json php7.4-mbstring php7.4-mysql php7.4-snmp php7.4-xml php7.4-zip python3-dotenv python3-pymysql python3-redis python3-setuptools python3-pip python3-systemd rrdtool snmp snmpd whois
Make sure to enter ‘y’ when prompted to confirm the installation.
- After the installation is complete, start and enable the necessary services by running the following commands:
sudo systemctl enable --now nginx sudo systemctl enable --now mariadb sudo systemctl enable --now php7.4-fpm sudo systemctl enable --now snmpd.service
Now that we have installed the required packages and started the necessary services, we can proceed to the next step.
Setting Up a New User for LibreNMS
In this step, we will create a new system user called ‘librenms’. This user will be used to run the LibreNMS monitoring tool.
- Create the ‘librenms’ user by executing the following command:
sudo useradd librenms -d /opt/librenms -M -r -s "$(which bash)"
Here’s a breakdown of the options used in the command:
-d /opt/librenms
: Sets the default home directory for the ‘librenms’ user to ‘/opt/librenms’.-M
: Prevents the creation of a home directory for the ‘librenms’ user.-r
: Marks the ‘librenms’ user as a system user.-s "$(which bash)"
: Sets the default shell for the ‘librenms’ user to ‘bash’.
- Set a password for the ‘librenms’ user by running the following command:
sudo passwd librenms
Enter a strong password for the user and confirm it.
Now we have created a new user for LibreNMS. Let’s move on to the next step.
Setting Up Timezone for the System and PHP
Timezone configuration is essential for accurate monitoring. In this step, we will set up the default timezone for both the system and PHP.
- Edit the ‘php.ini’ configuration files for PHP-FPM and CLI by executing the following commands:
sudo nano /etc/php/7.4/fpm/php.ini sudo nano /etc/php/7.4/cli/php.ini
Uncomment the ‘date.timezone’ option and set your desired timezone. For example, if you want to set the timezone to ‘Europe/Paris’, your configuration should look like this:
date.timezone = Europe/Paris
Save the changes and exit the editor.
- Restart PHP-FPM to apply the new configuration:
sudo systemctl restart php7.4-fpm
- Set the system timezone to match the PHP timezone by running the following command:
sudo timedatectl set-timezone Europe/Paris
Replace ‘Europe/Paris’ with your desired timezone.
Now the system and PHP are configured with the correct timezone settings. Let’s move on to the next step.
Setting Up MariaDB and Creating the Database
In this step, we will configure MariaDB as the database backend for LibreNMS and create a new database and user for the installation.
- Edit the MariaDB server configuration file ‘/etc/mysql/mariadb.conf.d/50-server.cnf’ using your preferred text editor:
sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
Add the following lines under the ‘[mysqld]’ section:
[mysqld] ... innodb_file_per_table=1 lower_case_table_names=0
Save the changes and exit the editor.
- Restart the MariaDB service to apply the new configuration:
sudo systemctl restart mariadb
- Log in to the MariaDB shell as the root user:
mysql -u root -p
Enter the password for the root user when prompted.
- Create a new database and user for LibreNMS by executing the following queries:
CREATE DATABASE librenms CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'librenms'@'localhost' IDENTIFIED BY 'LibreNMSPassword';
GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'localhost';
FLUSH PRIVILEGES;
Replace ‘LibreNMSPassword’ with a strong password of your choice.
Type ‘exit’ and press ‘Enter’ to exit the MariaDB shell.
Now we have set up MariaDB and created the necessary database and user for LibreNMS. Let’s move on to the next step.
Creating a New PHP-FPM Pool
PHP-FPM allows you to create custom pools for your PHP applications. In this step, we will create a new PHP-FPM pool specifically for LibreNMS.
- Copy the default pool configuration file ‘www.conf’ to ‘librenms.conf’ by running the following command:
sudo cp /etc/php/7.4/fpm/pool.d/www.conf /etc/php/7.4/fpm/pool.d/librenms.conf
- Edit the ‘librenms.conf’ file using your preferred text editor:
sudo nano /etc/php/7.4/fpm/pool.d/librenms.conf
In the ‘[librenms]’ section, change the default user and group from ‘[www]’ to ‘[librenms]’:
[librenms] ... user = librenms group = librenms
Also, change the default PHP-FPM sock file to ‘/run/php-fpm-librenms.sock’:
listen = /run/php-fpm-librenms.sock
Save the changes and exit the editor.
- Restart the PHP-FPM service to apply the new configuration:
sudo systemctl restart php7.4-fpm
- Verify that the ‘librenms’ sock file is created successfully by running the following command:
ss -anl | grep librenms
You should see an output similar to the following:
u_str LISTEN 0 511 /run/php/php-fpm-librenms.sock 69199 * 0 users:(("php-fpm7.4",pid=26105,fd=10),("php-fpm7.4",pid=26104,fd=10),("php-fpm7.4",pid=26103,fd=7))
Now we have created a new PHP-FPM pool for LibreNMS. Let’s move on to the next step.
Downloading LibreNMS
In this step, we will download the LibreNMS source code and set the necessary permissions and access control for it.
- Change your working directory to ‘/opt’ and download the LibreNMS source code by running the following commands:
cd /opt git clone https://github.com/librenms/librenms.git
The source code will be downloaded to the ‘/opt/librenms’ directory.
- Set the ownership and permissions for the LibreNMS installation:
sudo chown -R librenms:librenms /opt/librenms sudo chmod 771 /opt/librenms
- Set up Access Control Lists (ACLs) for the LibreNMS installation directory:
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/
Now we have downloaded LibreNMS and set up the necessary permissions and access control. Let’s move on to the next step.
Installing LibreNMS PHP Dependencies
To install the PHP dependencies for LibreNMS, we need to log in as the ‘librenms’ user and use the included composer_wrapper script.
- Log in as the ‘librenms’ user by running the following command:
su - librenms
- Install the PHP dependencies by executing the following command:
../scripts/composer_wrapper.php install --no-dev
Wait for the installation process to complete.
- Type ‘exit’ and press ‘Enter’ to log out from the ‘librenms’ user.
Now we have installed the PHP dependencies for LibreNMS. Let’s move on to the next step.
Configuring Nginx for LibreNMS
In this step, we will create a new Nginx server block specifically for LibreNMS.
- Create a new Nginx server block configuration file for LibreNMS using your preferred text editor:
sudo nano /etc/nginx/sites-available/librenms
Copy and paste the following configuration into the file. Replace ‘librenms.example.io’ with your desired domain name.
server { listen 80; server_name librenms.example.io; 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 ~ /\. { deny all; } }
Save the changes and exit the editor.
- Enable the new virtual host by creating a symbolic link:
sudo ln -s /etc/nginx/sites-available/librenms /etc/nginx/sites-enabled/
- Verify the Nginx configuration by running the following command:
sudo nginx -t
If the configuration is correct, you will see a message indicating that the test is successful.
- Restart the Nginx service to apply the new configuration:
sudo systemctl restart nginx
Now we have configured Nginx for LibreNMS. Let’s move on to the next step.
Starting the LibreNMS Installation
In this final step, we will start the LibreNMS installation process and configure it for optimal performance.
- Open your web browser and enter the LibreNMS domain name in the address bar. For example, if your domain name is ‘librenms.example.io’, enter:
https://librenms.example.io
- On the LibreNMS ‘Pre-Install Checks’ page, ensure that all checks have a green status mark. Click on the database icon to proceed.
- Enter the database name, user, and password that we created earlier. Click the ‘Check Credentials’ button to verify the database connection.
- Click the ‘Build Database’ button to import the database schema for LibreNMS.
- Click the key icon to create a new user for the LibreNMS admin. Enter the desired username, password, and email address, then click the ‘Add User’ button.
- Once the admin user is created, you will see the user details on the page.
- Click the checkmark icon to complete the installation. You will see the installation output.
- To finalize the installation, visit the LibreNMS validation page by entering the following URL in your browser:
https://librenms.example.io/validate
- You will be redirected to the LibreNMS login page. Enter the username and password for the admin user that you created earlier.
- On the LibreNMS validate page, you may encounter some errors. Follow the provided solutions to fix the errors specific to your installation.
- After fixing the errors, return to the LibreNMS validate page and reload it. Verify that all the status indicators show ‘OK’.
- Click on the ‘Overview’ menu to access the LibreNMS dashboard. Congratulations! You have successfully installed LibreNMS on Debian 11 Bullseye.
Conclusion
In this comprehensive guide, we have walked you through the step-by-step process of installing and configuring LibreNMS on Debian 11 Bullseye. By following this guide, you have set up a powerful network monitoring tool that will help you efficiently manage and monitor your network infrastructure.
Remember to regularly update and maintain your LibreNMS installation to ensure optimal performance and security. With LibreNMS and its extensive features, you can effectively monitor your network, receive alerts, and gain valuable insights to keep your infrastructure running smoothly.
If you’re looking for reliable and secure cloud hosting solutions, Shape.host offers Linux SSD VPS services that are perfectly suited for hosting LibreNMS and other monitoring tools. Visit Shape.host today to explore our hosting plans and experience top-notch performance and support.