How to install and configure LibreNMS on Ubuntu 16.04

In this article, we will show you how to install and configure LibreNMS on Ubuntu 16.04. LibreNMS is a free and open source auto-discovery network monitoring tool based on PHP / MYSQL / SNMP. It is a network monitoring system that provides support for a wide range of network hardware and operating systems, including FreeBSD, Cisco, Linux, HP, and more. LibreNMS is a community-based Observium network monitoring tool.

LibreNMS comes with a lot of useful features such as:

  • Automatic detection
  • Configurable emergency alert
  • API access
  • Billing system
  • Automatic update
  • Distributed polling
  • Apps for IOS and Android
  • Unix agent
  • And much more …

Installing and configuring LibreNMS on Ubuntu 16.04 is a fairly straightforward task if you follow our guide closely.

1. System update

Login to the server via SSH as superuser

ssh [email protected]_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 VPS

apt-get -y install apache2

After the web server is installed, start it and enable it to start at boot

systemctl start apache2
systemctl enable apache2

Create an Apache virtual host with the following content

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

<VirtualHost *:80>
DocumentRoot /opt/librenms/html/
ServerName yourdomain.ru

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

Power on the virtual host and restart Apache for the changes to take effect

a2ensite librenms.conf
a2enmod rewrite
systemctl restart apache2

3. Installing and configuring the 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

Then run the script mysql_secure_installation after installation to secure MariaDB server and set root password.

Now, log into the MariaDB server as root user and create a new user and database to install LibreNMS

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)]> FLUSH PRIVILEGES;
MariaDB [(none)]> exit

Remember to replace “PASSWORD” with your actual strong password.

Open the MariaDB config file and add the following lines to the appropriate section [mysqld]

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

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

Restart MariaDB for the changes to take effect.

systemctl restart mysql

4. Installing PHP 7

LibreNMS is a PHP application, so we need to install PHP. 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 for LibreNMS

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

6. Installing and configuring LibreNMS

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

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

Clone the LibreNMS source code via Git.

cd /opt/
git clone https://github.com/librenms/librenms.git librenms

Set correct permission on librenms directory

chown -R librenms:librenms /opt/librenms

To configure SNMPD copy the example config 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.

Then download the SNMPD distribution discovery script

curl -o /usr/bin/distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/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 to rotate old logs

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

7. Completing the installation

Finally, go to http://yourdomain.com/install.php and follow the onscreen instructions to complete the LibreNMS installation.

Sidebar