LibreNMS is a free and open source auto-discovering network monitoring tool for servers and network hardware. It supports wide range of network hardware and operating systems including Cisco, Linux, Juniper, Foundry, Windows, Brocade and many more. LibreNMS discover your network using OSPF, BGP, SNMP, CDP, FDP, LLDP and ARP protocols. LibreNMS comes with a lot of useful features including, Auto discovery, Email alert, Automatic Updates, iOS and Android App, Billing system and many more.
In this tutorial, we will install and configure LibreNMS on Ubuntu 16.04 with an Alibaba Cloud Elastic Compute Service (ECS) instance.
- A fresh Alibaba cloud Ubuntu 16.04 instance.
- A static IP address 192.168.0.103 is configured on the instance.
- A Root password is setup on the server.
Launch Alibaba Cloud ECS Instance
First, log in to your https://ecs.console.aliyun.com">Alibaba Cloud ECS Console. Create a new ECS instance, choosing Ubuntu 16.04 as the operating system with at least 2GB RAM. Connect to your ECS instance and log in as the root user.
Once you are logged into your Ubuntu 16.04 instance, run the following command to update your base system with the latest available packages.
apt-get update -y
Install LAMP Server
LibreNMS runs on the web server, written in PHP and uses MariaDB for database. So you will need to install Apache, PHP and MariaDB to your system.
First, install Apache and MariaDB by running the following command:
apt-get install apache2 mariadb-server -y
Once the installation is completed, start Apache and MariaDB service and enable them to start on boot:
systemctl start apache2
systemctl start mysql
systemctl enable apache2
systemctl enable mysql
By default, the latest version of PHP is not available in Ubuntu 16.04 default repository. So you will need to add the repository for that. You can add it by running the following command:
apt-get install software-properties-common -y
Next, update the repository and install PHP along with all the libraries by running the following command:
apt-get install libapache2-mod-php7.1 php7.1-cli php7.1-mysql php7.1-gd php7.1-snmp php-pear php7.1-curl snmp graphviz php7.1-mcrypt php7.1-json fping imagemagick whois mtr-tiny nmap python-mysqldb snmpd php-net-ipv4 php-net-ipv6 rrdtool git -y
Once all the packages are installed, enable required PHP modules with the following command:
Next, you will also set Time Zone in php.ini file:
Make the following changes:
date.time = Asia/Kolkata
Save and close the file.
By default, MariaDB installation is not secured. So you will need to secure it first. You can secure it by running the following script:
Answer all the questions as shown below:
Change the password for root ? N
Remove anonymous users? Y
Disallow root login remotely? Y
Remove test database and access to it? Y
Reload privilege tables now? Y
Once the MariaDB is secured, login to MariaDB shell using the following command:
mysql -u root -p
Enter your root password, then create a database and user for LibreNMS:
MariaDB [(none)]> CREATE DATABASE librenmsdb;
MariaDB [(none)]> CREATE USER 'librenmsuser'@'localhost' IDENTIFIED BY 'password';
Next, grant all privileges to the LibreNMS user:
MariaDB [(none)]> GRANT ALL PRIVILEGES ON librenmsdb.* TO 'librenmsuser'@'localhost';
Next, flush the privileges and exit from the MariaDB shell:
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> exit;
First, add new user with name librenms and make a member of the www-data group:
useradd librenms -d /opt/librenms -M -r
usermod -a -G librenms www-data
Next, change the directory to the /opt and download the latest version of LibreNMS using the following command:
git clone https://github.com/librenms/librenms.git librenms
Next, change the directory to the librenms and install all required dependencies by running the following command:
./scripts/composer_wrapper.php install --no-dev
Next, give proper permissions to the librenms directory:
chown -R librenms:librenms /opt/librenms/
chmod -R 755 /opt/librenms
Configure Apache for LibreNMS
Next, you will need to create an apache virtual host file for LibreNMS. You can do this with the following command:
Add the following lines:
CustomLog /opt/librenms/logs/access_log combined
Require all granted
Options FollowSymLinks MultiViews
Save and close the file, then enable virtual host and apache rewrite module with the following command:
Finally, restart the Apache service to apply all the changes:
systemctl restart apache2
Access LibreNMS Web Installation Wizard
Open your web browser and type the URL http://example.com, you will be redirected to the following page:
Make sure all the status is green, then click on the Next Stage button. You should see the following page:
Provide your database details, then click on the Next Stage button, you should see the following page:
Now, click on the Goto Add User button, you should see the following page:
Now, provide admin username, password and email address as you wish, then click on the Add User button. Once the user added successfully, you should see the following page:
Now, click on the Generate Config button, you should see the following page:
Now, click on the Finish install button, you should see the following page:
Now, click on “validate your install and fix any issues”, you will be redirected to the following page:
Here, provide your admin login details, then click on the Login button, you should see the following page:
Next, you will also need to configure Crontab and Logrotate for LibreNMS. so that automatic discovery and polling for newly added devices can happen automatically. First, change the directory to the librenms:
Copy the sample configuration file for crontab and logrotate with the following command:
cp librenms.nonroot.cron /etc/cron.d/librenms
cp misc/librenms.logrotate /etc/logrotate.d/librenms
Next, restart cron and logrotate using the following command:
systemctl restart cron
logrotate -f /etc/logrotate.conf
Now, validate the configuration by running the following command:
If everything is ok, you should see the following output:
Component | Version
--------- | -------
LibreNMS | 1.41-13-g447ae69
DB Schema | 253
PHP | 7.1.18-1+ubuntu16.04.1+deb.sury.org+1
MySQL | 10.0.34-MariaDB-0ubuntu0.16.04.1
RRDTool | 1.5.5
SNMP | NET-SNMP 5.7.3
====================================[OK] Composer Version: 1.6.5
[OK] Dependencies up-to-date.
[OK] Database connection successful
[OK] Database schema correct
Congratulations! You have successfully installed LibreNMS on Ubuntu 16.04 server. You can now add server and network devices to LibreNMS and monitor it from the central location.
Related Alibaba Cloud Products
Cloud Enterprise Network provides a hybrid and distributed global network, ideal for enterprise users with high demand on network coverage. Cloud Enterprise Network can be used to facilitate communication between VPC to VPC and VPC to IDC. With its stable transmission and next-generation network environment, the network provides high transmission speed and low latency for end-users.