bolt Valebyte VPS від $4/міс — NVMe, запуск за 60 секунд.

Отримати VPS arrow_forward
eco Початковий Туторіал

Installation and Configuration of Libre

calendar_month Aug 24, 2026 schedule 16 хв. читання visibility 19 переглядів
Установка и настройка LibreNMS на VPS для мониторинга сетевой инфраструктуры
info

Потрібен сервер для цього гайду? Ми пропонуємо виділені сервери та VPS у 50+ країнах з миттєвим налаштуванням.

Потрібен сервер для цього гайду?

Розгорніть VPS або виділений сервер за хвилини.

LibreNMS Installation and Configuration on a VPS for Network Infrastructure Monitoring

TL;DR

In this detailed guide, we will step-by-step configure LibreNMS on a modern VPS running Ubuntu 24.04 LTS, enabling you to effectively monitor the performance and status of your network infrastructure, servers, and applications. You will get a fully functional monitoring system capable of collecting data via SNMP, ICMP, and other protocols, visualizing it, and alerting you to problems.

  • Complete LibreNMS installation from scratch on Ubuntu 24.04 LTS.
  • Configuration of Nginx web server, PHP-FPM, and MariaDB database.
  • Securing the server with UFW and Fail2ban.
  • TLS/HTTPS configuration for secure web interface access.
  • Recommendations for backups and system maintenance.
  • Detailed section on troubleshooting common issues.

What we are configuring and why

Diagram: What we are configuring and why
Diagram: What we are configuring and why

Network infrastructure monitoring is a critically important task for any server owner, developer, or system administrator. It allows for timely problem identification, performance analysis, scaling planning, and downtime prevention. Today, we will install and configure LibreNMS – a powerful, open-source, and completely free monitoring system based on PHP/MySQL/SNMP. It provides a wide range of functions for collecting, analyzing, and visualizing data on the status of servers, network devices, applications, and services.

Ultimately, you will get a centralized dashboard that will display graphs of CPU load, memory usage, traffic, disk status, temperatures, and many other metrics for all your devices. You will be able to configure alerts for threshold breaches or service unavailability, receiving notifications via email, Slack, Telegram, or other channels. This will allow you to respond promptly to incidents and maintain the stability of your infrastructure.

There are various alternatives to LibreNMS, each with its own features. Popular solutions include Zabbix (more complex to set up, but very flexible), Prometheus + Grafana (a powerful stack for metrics, but requires separate exporter configuration), Observium (a commercial product with a limited free version), or cloud solutions such as Datadog, New Relic, Grafana Cloud. However, cloud services are often expensive and provide less control over data, and may not be suitable for monitoring private networks without additional VPN configuration. Self-hosting LibreNMS on a VPS gives full control over data, saves budget, and allows adapting the system to the unique requirements of your infrastructure, while ensuring high performance and flexibility.

What VPS configuration is needed for this task

Diagram: What VPS configuration is needed for this task
Diagram: What VPS configuration is needed for this task

Choosing the right VPS for LibreNMS depends on the number of devices you plan to monitor and the frequency of data collection. LibreNMS can be quite resource-intensive, especially if you have many devices and store data for a long period.

Minimum requirements (for 5-10 devices):

  • CPU: 2 cores (e.g., Intel Xeon E5 or equivalent).
  • RAM: 4 GB. LibreNMS, PHP-FPM, Nginx, and MariaDB consume a significant amount of memory.
  • Disk: 100 GB SSD. SSD is critical for database performance and RRD (Round Robin Database) files, where graphs are stored.
  • Network: 100 Mbps. This is usually sufficient for monitoring, unless your VPS is a central node for a huge amount of data.

Recommended VPS plan (for 20-50 devices):

For more serious use, including monitoring several dozen devices and storing history for several months, the following configuration is recommended:

  • CPU: 4 cores (e.g., Intel Xeon Gold or AMD EPYC).
  • RAM: 8 GB.
  • Disk: 200-300 GB NVMe SSD. NVMe will provide maximum speed for disk operations.
  • Network: 1 Gbps.

You can consider a VPS with the specified characteristics to host your LibreNMS instance. Make sure the chosen tariff plan offers sufficient memory and fast disk I/O.

When a dedicated server is needed, not a VPS

If you plan to monitor hundreds or thousands of devices, store data for years, or if you require very high performance and isolated resources, then you should consider a dedicated server. Dedicated servers provide the full power of physical hardware without virtualization, which is ideal for heavily loaded databases and intensive I/O operations. In this case, you can choose a suitable dedicated server to ensure the necessary level of performance and scalability.

Location: what it affects

The choice of VPS location is important for minimizing latency when collecting data. Place LibreNMS in the same region or as close as possible to the devices you plan to monitor. This will reduce the response time of SNMP queries and provide more accurate and timely data.

Server preparation

Before installing LibreNMS, you need to prepare your VPS. We will use Ubuntu Server 24.04 LTS as the operating system, as it is current and supported until 2029.

1. Connecting to the server

Connect to your VPS via SSH using the credentials provided by your provider. It is recommended to use SSH keys for greater security.


ssh root@your_vps_ip_address

2. Creating a new user with sudo privileges

Working as root is unsafe. Let's create a new user and add them to the sudo group.


adduser librenms_admin # Create a new user
usermod -aG sudo librenms_admin # Add them to the sudo group

Now exit root and log in as the new user:


exit
ssh librenms_admin@your_vps_ip_address

3. System update and installation of basic utilities

Let's update the package list and all installed packages, and also install the necessary utilities.


sudo apt update && sudo apt upgrade -y # Update package list and system
sudo apt install -y curl wget git vim htop screen unzip # Install basic utilities

4. Firewall configuration (UFW)

UFW (Uncomplicated Firewall) is an easy-to-use interface for iptables. Let's configure it to allow only the necessary ports.


sudo ufw allow OpenSSH # Allow SSH (port 22)
sudo ufw allow http # Allow HTTP (port 80)
sudo ufw allow https # Allow HTTPS (port 443)
sudo ufw allow 161/udp # Allow SNMP (port 161 UDP) - for receiving SNMP traps
sudo ufw enable # Enable the firewall
sudo ufw status # Check firewall status

The output of sudo ufw status should show the allowed ports.

5. Installing Fail2ban

Fail2ban helps protect your server from brute-force attacks by blocking IP addresses from which multiple failed login attempts have been detected.


sudo apt install -y fail2ban # Install Fail2ban
sudo systemctl enable fail2ban # Enable Fail2ban autostart
sudo systemctl start fail2ban # Start Fail2ban

Fail2ban is already configured by default to protect SSH. You can create a configuration file /etc/fail2ban/jail.local for more fine-grained settings, but this is not necessary to start.

Software installation — step-by-step

Software Installation — Step-by-Step

Diagram: Software Installation — Step-by-Step
Diagram: Software Installation — Step-by-Step

Now, let's proceed with installing all the necessary components for LibreNMS. We will use Nginx as the web server, PHP-FPM for processing PHP scripts, and MariaDB for the database.

1. Nginx Installation

Nginx is a high-performance web server that is excellent for static content and working with PHP-FPM.


sudo apt install -y nginx # Install Nginx
sudo systemctl enable nginx # Enable Nginx autostart
sudo systemctl start nginx # Start Nginx

You can verify that Nginx is running by navigating to your VPS's IP address in a browser. You should see the Nginx welcome page.

2. MariaDB Installation

MariaDB is a fork of MySQL, fully compatible with it, and often offers better performance.


sudo apt install -y mariadb-server mariadb-client # Install MariaDB server and client
sudo systemctl enable mariadb # Enable MariaDB autostart
sudo systemctl start mariadb # Start MariaDB
sudo mysql_secure_installation # Run script to secure MariaDB

During the execution of mysql_secure_installation, you will be prompted to set a password for the database root user, remove anonymous users, disallow remote root login, and remove the test database. It is recommended to answer "Y" to all questions.

3. PHP and PHP-FPM Installation

LibreNMS requires PHP. For 2026, PHP 8.2 or 8.3 (or even newer) will be current. Ubuntu 24.04 LTS typically comes with PHP 8.3.


sudo apt install -y php8.3-cli php8.3-fpm php8.3-mysql php8.3-gd php8.3-snmp php8.3-curl php8.3-xml php8.3-zip php8.3-mbstring php8.3-json php8.3-gmp php8.3-pear php8.3-bcmath php8.3-memcached php8.3-imagick php8.3-ssh2 php8.3-redis # Install PHP-FPM and necessary extensions
sudo systemctl enable php8.3-fpm # Enable PHP-FPM autostart
sudo systemctl start php8.3-fpm # Start PHP-FPM

It is also necessary to install some system packages that LibreNMS uses for data collection and graph processing.


sudo apt install -y snmp snmpd rrdtool fping imagemagick whois mtr-tiny nmap python3-pymysql python3-memcache python3-dotenv # Install additional utilities

4. PHP Configuration for LibreNMS

Let's edit the PHP-FPM configuration file to increase memory and execution time limits, which are necessary for LibreNMS.


sudo vim /etc/php/8.3/fpm/php.ini # Open PHP-FPM configuration file

Find the following lines and change their values:


memory_limit = 256M
max_execution_time = 300
date.timezone = Europe/Moscow ; or your timezone

Save the changes and restart PHP-FPM:


sudo systemctl restart php8.3-fpm

5. Composer Installation

Composer is a dependency manager for PHP, used by LibreNMS to install components.


curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer # Download and install Composer

6. Creating LibreNMS User and Cloning Repository

Let's create a separate system user for LibreNMS without SSH login capability and download the source code.


sudo useradd -r -M -d /opt/librenms librenms # Create librenms system user
sudo usermod -a -G librenms www-data # Add librenms user to www-data group (for Nginx)
sudo mkdir /opt/librenms # Create directory for LibreNMS
sudo chown librenms:librenms /opt/librenms # Set directory owner
sudo chmod 775 /opt/librenms # Set directory permissions
sudo su - librenms # Switch to librenms user
git clone https://github.com/librenms/librenms.git /opt/librenms # Clone LibreNMS repository
exit # Return to our sudo user

7. Installing LibreNMS Dependencies

Navigate to the LibreNMS directory and install all dependencies using Composer.


sudo su - librenms # Switch to librenms user
cd /opt/librenms # Navigate to LibreNMS directory
composer install --no-dev --optimize-autoloader # Install dependencies
exit # Return to our sudo user

8. Configuring LibreNMS File Permissions

It is necessary to set the correct permissions for some directories so that LibreNMS can write data.


sudo chown -R librenms:librenms /opt/librenms # Set owner for the entire directory
sudo setfacl -R -m g:www-data:rwX /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/ # Set ACL permissions for the web server
sudo setfacl -R -m o::--- /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/ # Deny access to others

Configuration

Diagram: Configuration
Diagram: Configuration

After installing all components, they need to be configured correctly.

1. MariaDB Database Configuration

Let's create a database and user for LibreNMS.


sudo mysql -u root -p # Connect to MariaDB as root (will require the password you set earlier)

Inside the MariaDB console, execute the following commands, replacing your_db_password with a strong password:


CREATE DATABASE librenms CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'librenms'@'localhost' IDENTIFIED BY 'your_db_password';
GRANT ALL PRIVILEGES ON librenms. TO 'librenms'@'localhost';
FLUSH PRIVILEGES;
EXIT;

2. Nginx Configuration for LibreNMS

Let's create an Nginx configuration file for LibreNMS. We will remove the default configuration and create a new one.


sudo rm /etc/nginx/sites-enabled/default # Remove default config
sudo vim /etc/nginx/sites-available/librenms.conf # Create new config

Paste the following content into the librenms.conf file. Replace your_domain_or_ip with your domain or VPS IP address.


server {
    listen 80;
    server_name your_domain_or_ip;
    root /opt/librenms/html;
    index index.php;

    charset utf-8;
    gzip on;
    gzip_types text/css application/javascript text/xml application/xml application/xml+rss text/javascript;

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

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }

    location ~ /.env {
        deny all;
    }

    location /images/os {
        deny all;
    }

    # Enable for LibreNMS API
    location /api {
        try_files $uri $uri/ /api_v2.php?$query_string;
    }
}

Save the file, create a symbolic link, and check the Nginx configuration, then restart it.


sudo ln -s /etc/nginx/sites-available/librenms.conf /etc/nginx/sites-enabled/ # Create symlink
sudo nginx -t # Check Nginx configuration for errors
sudo systemctl reload nginx # Restart Nginx

3. Basic LibreNMS Configuration

LibreNMS uses the config.php file for basic settings. Let's create it from the example.


sudo cp /opt/librenms/config.php.default /opt/librenms/config.php # Copy config template
sudo vim /opt/librenms/config.php # Open for editing

Find and edit the following lines, replacing the values with your own:


// Database config
$config['db_host'] = 'localhost';
$config['db_user'] = 'librenms';
$config['db_pass'] = 'your_db_password'; // The password you set for the librenms user
$config['db_name'] = 'librenms';

// Other settings
$config['snmp']['community'][] = 'public'; // Add your SNMP community strings
$config['rrd_dir'] = '/opt/librenms/rrd'; // Directory for RRD files
$config['log_dir'] = '/opt/librenms/logs'; // Directory for logs
$config['timezone'] = 'Europe/Moscow'; // Your timezone

Save the changes. Ensure that the timezone in config.php matches the timezone in php.ini.

4. Cron Job Configuration

LibreNMS uses cron jobs for regular device polling, data processing, and other background tasks.


sudo cp /opt/librenms/librenms.nonroot.cron /etc/cron.d/librenms # Copy cron file
sudo vim /etc/cron.d/librenms # Open for editing

Ensure that all lines start with librenms, as the user under which the tasks will be executed.


# /etc/cron.d/librenms: crontab entries for librenms

# Update LibreNMS every 5 minutes
/5     librenms /opt/librenms/discovery.php -h all >> /dev/null 2>&1
/5     librenms /opt/librenms/poller-wrapper.py 16 >> /dev/null 2>&1

# Daily maintenance tasks
15 0    librenms /opt/librenms/daily.sh >> /dev/null 2>&1

# Housekeeping
0 /6    librenms /opt/librenms/cronic /opt/librenms/db-schema-validate.php >> /dev/null 2>&1

Save the file.

5. SNMP Daemon (snmpd) Configuration

On the VPS where LibreNMS is installed, it is also useful to configure snmpd so that the LibreNMS server itself can be monitored as a regular device.


sudo vim /etc/snmp/snmpd.conf # Open snmpd configuration file

Comment out or remove the line agentAddress udp:127.0.0.1:161 and add agentAddress udp:161,udp6:[::1]:161 to listen on all interfaces.

Find the line rocommunity public default -V systemonly and change it to something like:


rocommunity your_snmp_community_string default -V systemonly

Replace your_snmp_community_string with your secure community string. Also, add the following line so that snmpd can retrieve information about disks and other metrics:


disk /

Save the changes and restart snmpd:


sudo systemctl restart snmpd

6. TLS/HTTPS Installation with Certbot

For secure access to the LibreNMS web interface, HTTPS needs to be configured. We will use Certbot to obtain and automatically renew Let's Encrypt SSL certificates.


sudo apt install -y certbot python3-certbot-nginx # Install Certbot and Nginx plugin
sudo certbot --nginx -d your_domain_or_ip # Run Certbot to obtain certificate

Follow Certbot's instructions. It will automatically modify the Nginx configuration, add necessary entries for HTTPS, and set up automatic certificate renewal.

7. Verifying Functionality

After all configurations, open your domain or IP address in a browser (now via HTTPS). You should see the LibreNMS installation page.

  • Step 1: Go to https://your_domain_or_ip.
  • Step 2: Follow the instructions of the LibreNMS web installer. It will check all dependencies. If there are warnings, make sure you have correctly performed all previous steps.
  • Step 3: Create the first administrative user.
  • Step 4: After completing the installation, you will be taken to the LibreNMS dashboard.

Now you can add your VPS with LibreNMS as a monitoring device, using the community string you configured in /etc/snmp/snmpd.conf.

Backups and Maintenance

Diagram: Backups and Maintenance
Diagram: Backups and Maintenance

Regular backups and maintenance are critical for any production system. LibreNMS is no exception.

What to Back Up

  • MariaDB Database: Contains all information about your devices, configurations, users, and event history.
  • LibreNMS Configuration Files: Especially /opt/librenms/config.php and any custom scripts or templates.
  • RRD Files: These files in /opt/librenms/rrd/ contain all graph data. They can be very large.

Simple Auto-Backup Script

Let's create a simple script for daily backups. The script will dump the database and archive configuration files and RRD data.


sudo mkdir -p /opt/librenms/backups # Create backup directory
sudo chown librenms:librenms /opt/librenms/backups # Set owner
sudo vim /opt/librenms/backup.sh # Create backup script

Insert the following content into backup.sh, replacing your_db_password with your LibreNMS database password.


#!/bin/bash

# Settings
DB_USER="librenms"
DB_PASS="your_db_password"
DB_NAME="librenms"
BACKUP_DIR="/opt/librenms/backups"
LIBRENMS_DIR="/opt/librenms"
TIMESTAMP=$(date +%Y%m%d%H%M%S)

# Create database dump
echo "Dumping database..."
mysqldump -u $DB_USER -p$DB_PASS $DB_NAME > $BACKUP_DIR/librenms_db_$TIMESTAMP.sql

# Archive configs and RRD
echo "Archiving configs and RRDs..."
tar -czvf $BACKUP_DIR/librenms_files_$TIMESTAMP.tar.gz \
    $LIBRENMS_DIR/config.php \
    $LIBRENMS_DIR/rrd \
    $LIBRENMS_DIR/logs \
    --exclude="$LIBRENMS_DIR/backups"

# Delete old backups (older than 7 days)
echo "Cleaning old backups..."
find $BACKUP_DIR -type f -name "librenms_*" -mtime +7 -delete

echo "Backup completed!"

Make the script executable and add it to cron.


sudo chmod +x /opt/librenms/backup.sh # Make the script executable
sudo crontab -e -u librenms # Open crontab for librenms user

Add the following line to the end of the cron file for daily backup execution (e.g., at 3:00 AM):


0 3 * * * /opt/librenms/backup.sh >> /opt/librenms/logs/backup.log 2>&1

Where to Store Backups

Storing backups on the same server as the original data is not secure. Consider the following options:

  • External S3-compatible storage: Use utilities like s3cmd or rclone to automatically synchronize backups with cloud storage (e.g., Amazon S3, DigitalOcean Spaces, Backblaze B2).
  • Separate VPS: Configure rsync over SSH to copy backups to another one of your VPS instances.
  • Local storage with encryption: For small volumes, local storage can be used, but it must be encrypted and regularly copied manually or via a script to an external drive.

Updates: rolling vs maintenance window

LibreNMS regularly releases updates. It is important to keep the system up to date.

  • Rolling updates: LibreNMS has a daily.sh script that performs code updates if run from cron. This is relatively safe for minor updates.
  • Maintenance window: For major updates (e.g., changing PHP version or OS kernel), a maintenance window is recommended.
    1. Stop the LibreNMS poller: sudo systemctl stop librenms-poller.service (if you are using a systemd service for the poller).
    2. Perform a full backup.
    3. Perform OS update: sudo apt update && sudo apt upgrade -y.
    4. Manually update LibreNMS: cd /opt/librenms && git pull && composer install --no-dev --optimize-autoloader && ./daily.sh.
    5. Check logs and the web interface.
    6. Start the poller: sudo systemctl start librenms-poller.service.

Troubleshooting + FAQ

Q: What is the minimum VPS configuration suitable for LibreNMS?

A: To start, if you plan to monitor up to 10 devices, the minimum acceptable configuration would be 2 CPU cores, 4 GB RAM, and 100 GB SSD. However, for stable operation and longer data retention, it is recommended to increase these parameters to 4 CPU cores, 8 GB RAM, and 200 GB NVMe SSD. This will ensure better database performance and a smoother web interface experience.

Q: What to choose — VPS or dedicated for this task?

A: For most individual users or small teams, a VPS will be the optimal choice, offering a good balance between cost and performance. However, if you manage a large infrastructure with hundreds or thousands of devices, require maximum disk subsystem performance, and want complete resource isolation, then a dedicated server will be a more suitable solution. It will provide you with full control over the hardware and guaranteed performance.

Q: LibreNMS web interface does not load or shows a 502 Bad Gateway error. What to do?

A: A 502 error usually indicates issues with PHP-FPM. Check the status of PHP-FPM: sudo systemctl status php8.3-fpm. Ensure it is running and active. Also, check Nginx logs (sudo tail /var/log/nginx/error.log) and PHP-FPM logs (sudo tail /var/log/php8.3-fpm.log or similar path). Often, the problem is related to incorrect file permissions, insufficient memory, or errors in PHP configuration.

Q: Devices are added, but graphs are empty or show no data.

A: This means that the LibreNMS poller cannot collect data via SNMP. Check the following:

  • Firewall: Ensure that UDP port 161 is open on the LibreNMS server and on the target device.
  • SNMP Community: Ensure that the SNMP community string in LibreNMS (in config.php and when adding a device) matches the one configured on the target device.
  • SNMP Daemon: On the target device, ensure that snmpd is running and correctly configured.
  • Poller: Run the poller manually for a single device: sudo su - librenms -c "/opt/librenms/poller.php -h <device_id_or_hostname> -r -f -d". This will provide detailed output about the data collection process.

Q: LibreNMS is slow, pages load for a long time.

A: Slow performance can be caused by several reasons:

  • Insufficient resources: Check CPU load, RAM usage, and disk I/O operations on your VPS (htop, iostat, free -h). If any resource is consistently overloaded, you might need a more powerful VPS.
  • MariaDB Optimization: Ensure that MariaDB is optimally configured. You can start by using the mysqltuner.pl script for recommendations.
  • PHP-FPM Workers: You might not have enough PHP-FPM processes. Edit /etc/php/8.3/fpm/pool.d/www.conf and increase pm.max_children, pm.start_servers, and other parameters, then restart PHP-FPM.
  • RRD Updates: Ensure that cron jobs are running correctly and there are no delays in updating RRD files.

Q: How to add a new device for monitoring?

A: After logging into the LibreNMS web interface, navigate to "Devices" -> "Add Device". You will need to specify the device's IP address or hostname, as well as the SNMP Community String. LibreNMS will automatically detect the device type and begin data collection.

Conclusion and Next Steps

Congratulations! You have successfully installed and configured LibreNMS on your VPS, creating a powerful and flexible system for monitoring your network infrastructure. You now have a centralized tool for tracking the status and performance of all your devices, which will significantly simplify management and reduce response time to potential issues. You can be confident that your infrastructure is under constant control.

Now that the basic setup is complete, you can move forward:

  • Adding Devices: Start adding all your servers, routers, switches, and other network devices to LibreNMS.
  • Configuring Alerts: Explore the LibreNMS alerting system. Set up notifications via email, Slack, Telegram, or other channels for timely information about critical events.
  • Exploring Features: LibreNMS has extensive functionality, including auto-discovery, custom graphs, network maps, and integrations. Take time to study the documentation and experiment with various features to maximize the potential of your new monitoring system.

Чи був цей гайд корисним?

Ваш відгук допомагає нам покращувати гайди.

Share this post:

Надішліть гайд тому, кому він може стати в пригоді.

Telegram VKVK WhatsApp Facebook LinkedIn XX

LibreNMS VPS setup Install LibreNMS on VPS Configure LibreNMS on
support_agent
Valebyte Support
Usually replies within minutes
Hi there!
Send us a message and we'll reply as soon as possible.