Install LibreNMS Ubuntu 20.04
Development Platform : Ubuntu Server 20.04 Web Server Nginx version 1.18.0 LibreNMS version 24.1.0 PHP version 8.2.15 python version 3.8.10 MariaDB version 10.3.39
Update Ubuntu Linux Server
sudo apt update && sudo apt upgrade -y
Install Required Packages
sudo apt install software-properties-common
sudo add-apt-repository universe
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install acl curl fping git graphviz imagemagick mariadb-client mariadb-server mtr-tiny nginx-full nmap php8.2-cli php8.2-curl php8.2-fpm php8.2-gd php8.2-gmp php8.2-mbstring php8.2-mysql php8.2-snmp php8.2-xml php8.2-zip rrdtool snmp snmpd unzip python3-pymysql python3-dotenv python3-redis python3-setuptools python3-systemd python3-pip whois traceroute
Add libreNMS user and set password for user librenms
sudo useradd librenms -d /opt/librenms -M -r -s "$(which bash)"
sudo passwd librenms
Clone libreNSM to /opt directory
cd /opt
sudo git clone <https://github.com/librenms/librenms.git>
Change Owner Permission and Acl
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 PHP Dependency
su - librenms
./scripts/composer_wrapper.php install --no-dev
exit
SET timezone
Ensure date.timezone is set in php.ini Ensure date.timezone is set in php.ini to your preferred time zone.
nano /etc/php/8.2/fpm/php.ini
nano /etc/php/8.2/cli/php.ini
Remember to set the system timezone as well.
timedatectl set-timezone Asia/Jakarta
Configure MariaDB
nano /etc/mysql/mariadb.conf.d/50-server.cnf
Within the [mysqld]
section add:
innodb_file_per_table=1
lower_case_table_names=0
restart and enable
systemctl enable mariadb
systemctl restart mariadb
Create database
sudo mysql -u root
CREATE DATABASE librenms CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'librenms'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'localhost';
exit
Configure PHP-FPM
sudo cp /etc/php/8.2/fpm/pool.d/www.conf /etc/php/8.2/fpm/pool.d/librenms.conf
sudo nano /etc/php/8.2/fpm/pool.d/librenms.conf
change [www] to [librenms]
[librenms]
change user and group to “librenms”, Change listen
to a unique path that must match your webserver’s config (fastcgi_pass
for NGINX and SetHandler
for Apache) :
user = librenms
group = librenms
listen = /run/php-fpm-librenms.sock
Configure Web Server
nano /etc/nginx/conf.d/librenms.conf
Add the following config, edit server_name
as required:
server {
listen 80;
server_name librenms.example.com;
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 ~ /\\.(?!well-known).* {
deny all;
}
}
rm /etc/nginx/sites-enabled/default
systemctl restart nginx
systemctl restart php8.2-fpm
Enable lnms command completion
This feature grants you the opportunity to use tab for completion on lnms commands as you would for normal linux commands.
sudo ln -s /opt/librenms/lnms /usr/bin/lnms
sudo ln -s /opt/librenms/lnms /usr/local/bin/lnms
sudo cp /opt/librenms/misc/lnms-completion.bash /etc/bash_completion.d/
Configure snmpd
cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf
nano /etc/snmp/snmpd.conf
Edit the text which says RANDOMSTRINGGOESHERE
and set your own community string.
sudo curl -o /usr/bin/distro <https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro>
sudo chmod +x /usr/bin/distro
systemctl enable snmpd
systemctl restart snmpd
Cron job
sudo cp /opt/librenms/dist/librenms.cron /etc/cron.d/librenms
Enable the scheduler
sudo cp /opt/librenms/dist/librenms-scheduler.service /opt/librenms/dist/librenms-scheduler.timer /etc/systemd/system/
sudo systemctl enable librenms-scheduler.timer
sudo systemctl start librenms-scheduler.timer
Copy logrotate config
LibreNMS keeps logs in /opt/librenms/logs
. Over time these can become large and be rotated out. To rotate out the old logs you can use the provided logrotate config file:
cp /opt/librenms/misc/librenms.logrotate /etc/logrotate.d/librenms
Web installer
Access the server ip port 80