Install LibreNMS on Ubuntu 22.04
Install LibreNMS on Ubuntu 22.04
Author: Josh Madrone
Date: Oct 19, 2025 at 3:59:35 PM
UUID: 03A9B556-2A20-4ABF-B696-AF99514F7A33
Hashtags: #librenms, #networking, #network-monitoring, #snmp, #linux, #ubuntu
LibreNMS is a powerful, open-source network monitoring solution that provides comprehensive insights into your network's performance and health.
At Emerald Security, we frequently deploy LibreNMS to monitor critical infrastructure for our clients.
This guide provides step-by-step instructions to install LibreNMS on a fresh Ubuntu 22.04 server, ensuring a secure and reliable setup.
Table of Contents
- Table of Contents
- Prerequisites
- Installation Instructions
- Step 1 - Update the System
- Step 2 - Install Required Dependencies
- Step 3 - Configure MariaDB
- Step 4 - Install LibreNMS
- Step 5 - Configure Apache Web Server
- Step 6 - Configure LibreNMS
- Step 7 - Configure SNMP (Optional)
- Step 8 - Complete the Installation via Web Interface
- Step 9 - Secure the Installation with SSL
- Step 10 - Set Up Polling and Discovery
- Step 11 - Verify the Installation
- Troubleshooting Tips
- Conclusion
Prerequisites
Before starting, ensure you have:
- A clean Ubuntu 22.04 server (LTS) with at least 2GB of RAM and 20GB of disk space.
- Root or sudo privileges.
- A domain name or static IP address for accessing the web interface.
- Basic familiarity with Linux command-line operations.
📝 Note
Always perform installations and configurations as a non-root user with sudo privileges unless otherwise specified.
Installation Instructions
Step 1 - Update the System
Start by updating your Ubuntu 22.04 server to ensure all packages are current.
sudo apt update && sudo apt upgrade -y
Step 2 - Install Required Dependencies
LibreNMS requires several packages, including a web server, database, and PHP. Install these dependencies using the following command:
sudo apt install -y apache2 mariadb-server mariadb-client php php-mysql php-gd php-snmp php-curl php-mbstring php-xml php-bcmath php-zip php-pear python3 python3-pip python3-dev composer fping imagemagick whois mtr-tiny nmap acl unzip git
Step 3 - Configure MariaDB
LibreNMS uses MariaDB as its database backend. Secure the MariaDB installation and create a database for LibreNMS.
Run the secure installation script:
sudo mysql_secure_installation
Follow the prompts to set a root password, remove anonymous users, disallow remote root login, and remove the test database.
Log in to MariaDB:
sudo mysql -u root -pCreate a database and user for LibreNMS:
CREATE DATABASE librenms CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; CREATE USER 'librenms'@'localhost' IDENTIFIED BY 'StrongPassword123'; GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'localhost'; FLUSH PRIVILEGES; EXIT;
Replace StrongPassword123
with a secure password of your choice.
Step 4 - Install LibreNMS
Create a directory for LibreNMS and set appropriate permissions:
sudo mkdir -p /opt/librenms sudo useradd -r -M -d /opt/librenms librenms sudo chown -R librenms:librenms /opt/librenms sudo chmod 770 /opt/librenms sudo setfacl -d -m g::rwx /opt/librenmsClone the LibreNMS repository:
sudo -u librenms git clone https://github.com/librenms/librenms.git /opt/librenmsInstall PHP dependencies using Composer:
sudo -u librenms composer install --no-dev -d /opt/librenms
Step 5 - Configure Apache Web Server
Create an Apache virtual host configuration for LibreNMS:
sudo nano /etc/apache2/sites-available/librenms.confAdd the following configuration, replacing
your-domain.com
with your domain or server IP:<VirtualHost *:80> ServerName your-domain.com DocumentRoot /opt/librenms/html AllowEncodedSlashes NoDecode <Directory "/opt/librenms/html"> Options FollowSymLinks AllowOverride All Require all granted </Directory> ErrorLog /opt/librenms/logs/error.log CustomLog /opt/librenms/logs/access.log combined </VirtualHost>Enable the site and required Apache modules:
sudo a2ensite librenms.conf sudo a2enmod rewrite sudo systemctl restart apache2
Step 6 - Configure LibreNMS
Copy the sample configuration file and edit it:
sudo -u librenms cp /opt/librenms/config.php.default /opt/librenms/config.php sudo nano /opt/librenms/config.phpUpdate the following settings in
config.php
:<?php $config['db']['host'] = 'localhost'; $config['db']['database'] = 'librenms'; $config['db']['username'] = 'librenms'; $config['db']['password'] = 'StrongPassword123';Replace
StrongPassword123
with the password you set earlier.Initialize the database:
sudo -u librenms php /opt/librenms/build-base.phpSet up log rotation:
sudo -u librenms ln -s /opt/librenms/librenms.nonroot.cron /etc/cron.d/librenms sudo cp /opt/librenms/misc/librenms.logrotate /etc/logrotate.d/librenms
Step 7 - Configure SNMP (Optional)
If you plan to monitor devices using SNMP, ensure the snmpd
service is installed and configured:
sudo apt install -y snmpd
sudo nano /etc/snmp/snmpd.conf
Add a basic community string for monitoring:
rocommunity public localhost
Restart the SNMP service:
sudo systemctl restart snmpd
Step 8 - Complete the Installation via Web Interface
- Open your browser and navigate to
http://your-domain.com
orhttp://your-server-ip
. - Follow the web-based installer to complete the setup. Ensure the pre-install checks pass, and enter the database credentials when prompted.
- Create an admin user for LibreNMS.
Step 9 - Secure the Installation with SSL
To secure your LibreNMS instance, install a Let’s Encrypt SSL certificate using Certbot:
Install Certbot:
sudo apt install -y certbot python3-certbot-apacheObtain and install an SSL certificate:
sudo certbot --apache -d your-domain.comFollow the prompts to configure HTTPS and redirect HTTP traffic to HTTPS.
Step 10 - Set Up Polling and Discovery
Add a device to monitor:
sudo -u librenms /opt/librenms/addhost.php <device-ip> public v2cReplace
<device-ip>
with the IP address of the device you want to monitor andpublic
with your SNMP community string.Run a manual discovery and poll:
sudo -u librenms /opt/librenms/discovery.php -h all sudo -u librenms /opt/librenms/poller.php -h allEnsure cron jobs are running for automated polling and discovery:
sudo -u librenms /opt/librenms/cronic /opt/librenms/discovery-wrapper.py 1 sudo -u librenms /opt/librenms/cronic /opt/librenms/poller-wrapper.py 1
Step 11 - Verify the Installation
- Log in to the LibreNMS web interface and verify that your devices are being monitored.
- Check the
/opt/librenms/logs/librenms.log
file for any errors. - Ensure that graphs and alerts are populating correctly.
Troubleshooting Tips
- Web interface not loading: Verify Apache is running (
sudo systemctl status apache2
) and check the virtual host configuration. - Database connection errors: Confirm the credentials in
/opt/librenms/config.php
match those set in MariaDB. - SNMP issues: Ensure the monitored device has SNMP enabled and the community string matches.
- Permission errors: Recheck ownership and permissions for
/opt/librenms
(sudo chown -R librenms:librenms /opt/librenms
).
Conclusion
You’ve successfully installed LibreNMS on Ubuntu 22.04! This setup provides a robust platform for monitoring your network infrastructure.
For advanced configurations, such as setting up alerts or integrating with other tools, refer to the LibreNMS documentation.
Stay tuned to the Emerald Security blog for more tech tutorials and best practices!