How to Install and Configure LibreNMS on Ubuntu 16.04

 In Dedicated, VPS

1. Update the system

Login to your server via SSH as user root

ssh root@IP_Address

and update all installed packages

apt-get update && apt-get upgrade

2. Install Apache web server

Run the following command to install Apache web server on your Ubuntu 16.04 system

apt-get -y install apache2

Once the web server is installed, start it and enable it to start on boot

systemctl start apache2
systemctl enable apache2

Create Apache virtual host with the following content

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

<VirtualHost *:80>
DocumentRoot /opt/librenms/html/

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

enable the virtual host and restart Apache for the changes to take effect

a2ensite librenms.conf
a2enmod rewrite
systemctl restart apache2

3. Install and configure MariaDB server

Install MariaDB server, start it and enable it to start automatically at system boot

apt-get install -y mariadb-client mariadb-server
systemctl start mysql
systemctl enable mysql

Next, run the mysql_secure_installation post installation script to secure the MariaDB server and set root password.

Now, login to the MariaDB server as user root and create a new user and database for the LibreNMS installation

MariaDB [(none)]> CREATE DATABASE librenms CHARACTER SET utf8 COLLATE utf8_unicode_ci;
MariaDB [(none)]> CREATE USER 'librenms'@'localhost' IDENTIFIED BY 'PASSWORD';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'localhost';
MariaDB [(none)]> exit

Don’t forget to replace ‘PASSWORD’ with an actual strong password.

Open the MariaDB configuration file and add the following lines under [mysqld] section

nano /etc/mysql/mariadb.conf.d/50-server.cnf


Restart MariaDB for the changes to take effect.

systemctl restart mysql

4. Install PHP 7

LibreNMS is a PHP based application, so we have to install PHP too. Run the following command to install PHP 7 and some additional PHP modules required by LibreNMS

apt-get install php7.0-cli php7.0-curl php7.0-gd php7.0-json php7.0-mcrypt php7.0-mysql php7.0-snmp php7.0-xml php7.0-zip libapache2-mod-php7.0

5. Install additional required packages

Install the following packages required by LibreNMS

apt-get install composer fping git graphviz imagemagick mtr-tiny nmap python-memcache python-mysqldb rrdtool snmp snmpd whois

6. Install and configure LibreNMS

Create a system user under which LibreNMS will run, and set the its home directory to /opt/librenms

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

Clone the LibreNMS source code through Git.

cd /opt/
git clone librenms

set the correct permission to the librenms directory

chown -R librenms:librenms /opt/librenms

To configure snmpd, copy the example configuration file

cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf

Open the snmpd.conf file, edit the RANDOMSTRINGGOESHERE line and set your own community string.

Next, download the snmpd distro detection script

curl -o /usr/bin/distro

make it executable and restart the service

chmod +x /usr/bin/distro
systemctl restart snmpd

Now, copy the cron script provided by LibreNMS to the ‘/ect/cron.d’ directory.

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

Copy the logrotate script too, in order to rotate the old logs

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

7. Finalize the installation

Finally, go to and follow the on-screen instructions to complete the LibreNMS installation.

Recommended Posts

Start typing and press Enter to search