Previous Page

nihilist - 18 / 09 / 2020

LibreNMS Debian 10 NGINX Setup

Before we start, you will need a Debian 10 VPS (you can get one on digitalocean for example), if you prefer to use your own self hosted server, make sure that port 80 and 443 are correctly port forwarded so that the public ip points to the server and not the router. Once that's done, go and ssh into your debian 10 server.

Initial Setup

First we get every package we need:

apt-get -y install apt-transport-https lsb-release ca-certificates curl gnupg -y
apt-get update -y

apt install acl curl socat composer fping git graphviz imagemagick mariadb-server mtr-tiny nginx-full nmap php7.3-cli php7.3-mysqlnd php7.3-curl php7.3-fpm php7.3-gd php7.3-json php7.3-mbstring php7.3-pgsql php7.3-snmp php7.3-xml php7.3-zip python-memcache python-mysqldb rrdtool snmp snmpd whois python3-pymysql python3-dotenv python3-redis python3-setuptools -y

Then we add the librenms user

useradd librenms -d /opt/librenms -M -r
usermod -a -G librenms www-data 

Next we install LibreNMS:

cd /opt
git clone

chown -R librenms:librenms /opt/librenms
chmod 770 /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/

Next we'll install the php dependencies:

su - librenms
./scripts/composer_wrapper.php install --no-dev

Configuring MySQL, NGINX, snmpd and cron

From here, we need to install MySQL:

service mysql restart

mysql -u root -p

CREATE DATABASE librenms CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE USER 'librenms'@'localhost' IDENTIFIED BY 'P@SSW0RD';
GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'localhost';

Take note here that we are using the password 'P@SSW0RD'

Now we'll edit mariadb's configuration:

echo 'innodb_file_per_table=1' >> /etc/mysql/mariadb.conf.d/50-server.cnf
echo 'lower_case_table_names=0' >> /etc/mysql/mariadb.conf.d/50-server.cnf

service mysql restart

Next we edit php.ini:

cd /etc/php/7.3/

echo 'date.timezone = Europe/Paris' >> fpm/php.ini
echo 'date.timezone = Europe/Paris' >> cli/php.ini

service php7.3-fpm restart

Before we configure NGINX, we need to get a domain name, so if you don't have it, go and get one make sure it points to your server's public ip address, if you don't want to pay for a domain name just go on DuckDNS.

Now we will configure NGINX:

First of all, we'll get the free SSL certificate:

wget -O - | sh
source ~/.bashrc

Here you verify your ip domain name is correctly setup like so:

Once there we can use to get the free SSL certificate:

systemctl stop nginx --issue --standalone -d -k 4096
systemctl start nginx 

From here we need to make sure the nginx configuration is correct:

rm /etc/nginx/sites-enabled/default
wget -O /etc/nginx/sites-available/librenms.vhost
nano /etc/nginx/sites-available/librenms.vhost

Make sure you change the librenms.vhost server_name line to your domain name:

Once you're done, do the following:

ln -s /etc/nginx/sites-available/librenms.vhost /etc/nginx/sites-enabled/librenms.vhost
nginx -t
service nginx reload

If nginx doesn't accept your configuration, you most probably made a mistake changing the domain name, so double check and correct it until nginx successfully reloads the configuration.

Next we'll configure SNMPD

cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf
chmod 600 /etc/snmp/snmpd.conf
nano /etc/snmp/snmpd.conf

in snmpd.conf make sure you change the text "RANDOMSTRINGGOESHERE" and change it to your community string

curl -o /usr/bin/distro
chmod +x /usr/bin/distro
service snmpd restart

Now we'll setup Cronjob:

cp /opt/librenms/librenms.nonroot.cron /etc/cron.d/librenms

copy logrotate config:

cp /opt/librenms/misc/librenms.logrotate /etc/logrotate.d/librenms

And we should be done!

Final Steps

Now that's done, just go to the URL of your website :

after that, head over to the database installation tab and just put in the password you put earlier (here it's P@SSW0RD)

Here just hit "build database"

Create the admin user:

Here for some reason it failed to write to the .env file so we manually edit it:

nano /opt/librenms/.env

just delete every line (ctrl+k) and then paste in the contents of the file shown on the webpage (CTRL+SHIFT+V), then hit CTRL+S to save and CTRL+X to exit

And that's it! All that's left is for you to login and setup the rest of librenms

Take note here that the ech2 community input field is the community "randomstringgoeshere" we put in the snmpd.conf earlier


Until there is Nothing left.

About nihilist

Donate XMR: 8AUYjhQeG3D5aodJDtqG499N5jXXM71gYKD8LgSsFB9BUV1o7muLv3DXHoydRTK4SZaaUBq4EAUqpZHLrX2VZLH71Jrd9k8

Contact: (PGP)