How to Install LibreNMS with Nginx on Ubuntu 22.04



How to Install LibreNMS with Nginx on Ubuntu 22.04

How to Install LibreNMS with Nginx on Ubuntu 22.04

LibreNMS is a free, open-source, and powerful network monitoring tool for Linux-based operating systems. It allows you to monitor all major operating systems as well as network devices including Cisco, Juniper, Foundry, FreeBSD, Brocade, and many more via a web browser. LibreNMS uses several network protocols like SNMP, ARP, CDP, FDP, LLDP, OSPF, and BGP to auto-discover all network operating systems and devices. It offers a wide range of features including, auto-discovery, API access, customizable alerts, automatic updates, and many more.

In this video, we will show you step-by-step instructions on how to install LibreNMS on Ubuntu 22.04.

Useful Links
VPS/VDS – https://www.mivocloud.com/
LibreNMS – https://www.librenms.org/

Commands Used
apt-get install rrdtool whois fping imagemagick graphviz mtr-tiny nmap python3-mysqldb snmp snmpd python3-pip python3-memcache mtr-tiny acl unzip git curl wget -y
apt-get install nginx mariadb-server php php-pear php-cgi php-common php-curl php-mbstring php-gd php-mysql php-bcmath php-imap php-json php-xml php-snmp php-fpm php-zip -y
nano /etc/php/8.1/fpm/php.ini
nano /etc/php/8.1/cli/php.ini
systemctl restart php8.1-fpm
mysql
create database librenmsdb CHARACTER SET utf8 COLLATE utf8_unicode_ci;
grant all privileges on librenmsdb.* to librenms@localhost IDENTIFIED by “password”;
flush privileges;
nano /etc/mysql/mariadb.conf.d/50-server.cnf

innodb_file_per_table=1
sql-mode=””
lower_case_table_names=0

systemctl restart mariadb
useradd -r -M -d /opt/librenms librenms
usermod -a -G librenms www-data
cd /opt
git clone https://github.com/librenms/librenms.git librenms
touch /opt/librenms/logs/librenms.log
cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf
nano /etc/snmp/snmpd.conf

com2sec readonly default mysnmpserverkey

curl -o distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro
chmod +x distro
mv distro /usr/bin/distro
systemctl restart snmpd
cp /opt/librenms/librenms.nonroot.cron /etc/cron.d/librenms
cp /opt/librenms/misc/librenms.logrotate /etc/logrotate.d/librenms
cd /opt/librenms
./scripts/composer_wrapper.php install –no-dev
chown -R www-data:librenms /opt/librenms
chmod -R 775 /opt/librenms
setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
setfacl -R -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
nano /etc/nginx/conf.d/librenms.conf

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 /api/v0 {
try_files $uri $uri/ /api_v0.php?$query_string;
}
location ~ .php {
include fastcgi.conf;
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
}
location ~ /.ht {
deny all;
}
}

nginx -t
systemctl restart php8.1-fpm
systemctl stop apache2
systemctl restart nginx
systemctl status nginx