Install LibreNMS on Debian/Ubuntu 🌱

  1. Log into the Debian device
  2. Run the following commands in a terminal:
    # update software repositories
    sudo apt update
    # install software updates
    sudo apt upgrade -y
    # install pre-requisites
    sudo apt install acl curl composer fping git graphviz imagemagick mariadb-client mariadb-server mtr-tiny nmap rrdtool snmp snmpd whois unzip python3-pymysql python3-dotenv python3-redis python3-setuptools python3-systemd python3-pip -y
    # install Apache and MySQL
    sudo apt install apache2 libapache2-mod-fcgid mariadb-server mariadb-client -y
    # install PHP components
    sudo apt install php7.3-cli php7.3-curl php7.3-fpm php7.3-gd php7.3-json php7.3-mbstring php7.3-mysql php7.3-snmp php7.3-xml php7.3-zip -y
    # create librenms user
    sudo useradd librenms -d /opt/librenms -M -r -s "$(which bash)"
    # clone librenms github repo
    sudo git clone https://github.com/librenms/librenms.git /opt/librenms
    # set permissions
    sudo chown -R librenms:librenms /opt/librenms
    sudo chmod 771 /opt/librenms
    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/
    # install composer dependencies
    sudo su - librenms
    ./scripts/composer_wrapper.php install --no-dev
    exit
    # set time zone for PHP fpm
    sudo nano /etc/php/7.3/fpm/php.ini
  3. Press CTRL+W to search > type timezone > Press Enter
  4. Remove the ; to uncomment the line
  5. Type in a valid timezone (https://php.net/manual/en/timezones.php)
  6. Press CTRL+O, Enter, CTRL+X to write the changes to php.ini
  7. Continue with the following commands in a terminal:
    # set time zone for PHP cli
    sudo nano /etc/php/7.3/cli/php.ini
  8. Press CTRL+W to search > type timezone > Press Enter
  9. Remove the ; to uncomment the line
  10. Type in a valid timezone (https://php.net/manual/en/timezones.php)
  11. Press CTRL+O, Enter, CTRL+X to write the changes to php.ini
  12. Continue with the following commands in a terminal:
  13. # set system time zone
    sudo timedatectl set-timezone America/New_York
    # edit mariaDB configuration
    sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
  14. Paste the following under the [mysqld] section

    innodb_file_per_table=1
    lower_case_table_names=0

  15. Press CTRL+O, Enter, CTRL+X to write the changes to 50-server.cnf
  16. Continue with the following commands in a terminal:
    # restart mariadb service
    sudo systemctl restart mariadb
    # configure the MySQL database
    sudo su
    mysql_secure_installation
  17. Press Enter to login as root
  18. Type Y and press Enter to set a root password, type the password twice to confirm
  19. Type Y and press Enter to remove anonymous users
  20. Type Y and press Enter to disallow root login remotely
  21. Type Y and press Enter to remove the test database
  22. Type Y and press Enter to reload privilege tables
  23. Run the following command to login into MySQL:
    mysql -u root -p
  24. Authenticate with the root password set earlier
  25. Run the following commands to create the LibreNMS database and database user
    CREATE DATABASE librenms CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
    CREATE USER 'librenms_rw'@'localhost' IDENTIFIED BY 'Libr3NM$!';
    GRANT ALL PRIVILEGES ON librenms.* TO 'librenms_rw'@'localhost';
    FLUSH PRIVILEGES;
    EXIT;
    exit
  26. Continue with the following commands:
    # make a copy of www.conf
    sudo cp /etc/php/7.3/fpm/pool.d/www.conf /etc/php/7.3/fpm/pool.d/librenms.conf
    # edit librenms.conf
    sudo nano /etc/php/7.3/fpm/pool.d/librenms.conf
  27. Replace [www] with [librenms]
  28. Change the user and group to librenms

    user = librenms
    group = librenms

  29. Change the listen to php-fpm-librenms.sock

    listen = /run/php-fpm-librenms.sock

  30. Press CTRL+O, Enter, CTRL+X to write the changes to librenms.conf
  31. Continue with the following commands:
    # create librenms apache conf
    sudo nano /etc/apache2/sites-available/librenms.conf
  32. Paste the following configuration into librenms.vhost

    <VirtualHost *:80>
    DocumentRoot /opt/librenms/html/
    #ServerName librenms.example.com

    AllowEncodedSlashes NoDecode
    <Directory "/opt/librenms/html/">
    Require all granted
    AllowOverride All
    Options FollowSymLinks MultiViews
    </Directory>

    # Enable http authorization headers
    <IfModule setenvif_module>
    SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
    </IfModule>

    <FilesMatch ".+\.php$">
    SetHandler "proxy:unix:/run/php-fpm-librenms.sock|fcgi://localhost"
    </FilesMatch>
    </VirtualHost>

  33. Press CTRL+O, Enter, CTRL+X to write the changes to librenms.conf
  34. Continue with the following commands:
    # enable the librenms site and reload apache
    sudo a2dissite 000-default
    sudo a2enmod proxy_fcgi setenvif rewrite
    sudo a2ensite librenms.conf
    sudo systemctl restart apache2
    sudo systemctl restart php7.3-fpm
    # install dispatcher service
    sudo su - librenms
    pip3 install -r requirements.txt
    exit
    sudo cp /opt/librenms/misc/librenms.service /etc/systemd/system/librenms.service
    sudo systemctl enable --now librenms.service
    # enable snmp
    sudo cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf
    sudo nano /etc/snmp/snmpd.conf
  35. Change RANDOMSTRINGGOESHERE to a unique community string to use for SNMP
  36. Press CTRL+O, Enter, CTRL+X to write the changes to snmpd.conf
  37. Continue with the following commands:
    # download librenms snmp
    sudo curl -o /usr/bin/distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro
    # set permissions
    sudo chmod +x /usr/bin/distro
    # restart snmp service
    sudo systemctl enable snmpd
    sudo systemctl restart snmpd
  38. Open a web browser and navigate to http://DNSorIP//install
  39. The LibreNMS setup screen should be displayed
  40. Click the Configure Database icon
  41. Select MySQL and fill out the database connection information as follows

    Host: localhost
    Port: 3306
    User: librenms_rw
    Password: Libr3NM$!
    Database Name: librenms

  42. Click the Check Credentials button
  43. Click the Build Database button
  44. Once the database has been created successfully, click the Created Admin User icon
  45. Enter a username, password and email address > Click the Add User button
  46. Click the Finish Install icon
  47. Click the validate your install link
  48. Log in using the admin user credentials created earlier
  49. Welcome to LibreNMS

Source: https://docs.librenms.org/Installation/Install-LibreNMS/

Check out for day in life on YouTube for more on LibreNMS: https://www.youtube.com/playlist?list=PLxiGkbpIzunT_YOwUEukOB6DpF8N8MXkQ