/** * 1) Run Highlight.js on all blocks * 2) Add VS Code-style line-number gutter * 3) Wrap bash/sh blocks in a Mac terminal chrome container with auto label * 4) Preserve existing inner HTML (spans) and logical lines */ (function(){ // 1) Highlight everything hljs.highlightAll();// Utility: split innerHTML by newlines while preserving markup function wrapLinesPreserveHTML(codeEl){ // Avoid double-processing if (codeEl.dataset.linesWrapped === "1") return;// Normalize line breaks const html = codeEl.innerHTML.replace(/rn/g, 'n').replace(/r/g, 'n'); const parts = html.split('n'); const wrapped = parts.map(line => `${line || '​'}`).join('n'); codeEl.innerHTML = wrapped; codeEl.dataset.linesWrapped = "1"; }// 2) Add gutter + 3) Terminal chrome for bash/sh document.querySelectorAll('pre > code').forEach(code => { const pre = code.parentElement;// Apply line numbers (gutter) only once if (!pre.classList.contains('with-gutter')) { pre.classList.add('with-gutter'); if (!code.classList.contains('hljs')) code.classList.add('hljs'); // ensure class for padding/colors wrapLinesPreserveHTML(code); }// Terminal chrome for bash/sh only const langMatch = (code.className || '').match(/language-([a-z0-9+_-]+)/i); const language = langMatch ? langMatch[1] : ''; const isShell = /^(ba?sh|sh)$/.test(language);if (isShell) { // Avoid double-wrapping if (!pre.parentElement || !pre.parentElement.classList.contains('code-terminal')) { // Build chrome const wrapper = document.createElement('div'); wrapper.className = 'code-terminal';const bar = document.createElement('div'); bar.className = 'term-bar';const dots = document.createElement('span'); dots.className = 'term-dots'; dots.innerHTML = '';const title = document.createElement('span'); title.className = 'term-title'; title.textContent = (language || 'bash');bar.appendChild(dots); bar.appendChild(title);// Insert wrapper around
        pre.parentNode.insertBefore(wrapper, pre);
        wrapper.appendChild(bar);
        wrapper.appendChild(pre);
      }
    }
  });
})();





	
	




  




		
Now Hiring: Do not apply for this junior installation engineer’s job. It’s highly unlikely you’d enjoy it

Install LibreNMS on Ubuntu 22.04

Install LibreNMS on Ubuntu 22.04

Install Guide / Linux / Network Monitoring / Networking
Install LibreNMS on Ubuntu 22.04.markdown

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

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.

  1. 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.

  1. Log in to MariaDB:

    sudo mysql -u root -p
  2. Create 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

  1. 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/librenms
  2. Clone the LibreNMS repository:

    sudo -u librenms git clone https://github.com/librenms/librenms.git /opt/librenms
  3. Install PHP dependencies using Composer:

    sudo -u librenms composer install --no-dev -d /opt/librenms

Step 5 - Configure Apache Web Server

  1. Create an Apache virtual host configuration for LibreNMS:

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

    Add 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>
  2. Enable the site and required Apache modules:

    sudo a2ensite librenms.conf sudo a2enmod rewrite sudo systemctl restart apache2

Step 6 - Configure LibreNMS

  1. 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.php

    Update 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.

  2. Initialize the database:

    sudo -u librenms php /opt/librenms/build-base.php
  3. Set 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

  1. Open your browser and navigate to http://your-domain.com or http://your-server-ip.
  2. Follow the web-based installer to complete the setup. Ensure the pre-install checks pass, and enter the database credentials when prompted.
  3. 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:

  1. Install Certbot:

    sudo apt install -y certbot python3-certbot-apache
  2. Obtain and install an SSL certificate:

    sudo certbot --apache -d your-domain.com

    Follow the prompts to configure HTTPS and redirect HTTP traffic to HTTPS.

Step 10 - Set Up Polling and Discovery

  1. Add a device to monitor:

    sudo -u librenms /opt/librenms/addhost.php <device-ip> public v2c

    Replace <device-ip> with the IP address of the device you want to monitor and public with your SNMP community string.

  2. Run a manual discovery and poll:

    sudo -u librenms /opt/librenms/discovery.php -h all sudo -u librenms /opt/librenms/poller.php -h all
  3. Ensure 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!

Select the fields to be shown. Others will be hidden. Drag and drop to rearrange the order.
  • Image
  • SKU
  • Rating
  • Price
  • Stock
  • Availability
  • Add to cart
  • Description
  • Content
  • Weight
  • Dimensions
  • Additional information
Click outside to hide the comparison bar
Compare