How to Install LibreNMS on Ubuntu 16.04

Prerequisites

  1. A fresh Alibaba cloud Ubuntu 16.04 instance.
  2. A static IP address 192.168.0.103 is configured on the instance.
  3. 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.

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.

apt-get install apache2 mariadb-server -y
systemctl start apache2
systemctl start mysql
systemctl enable apache2
systemctl enable mysql
apt-get install software-properties-common -y
add-apt-repository ppa:ondrej/php
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
phpenmod mcrypt
a2enmod php7.1
a2dismod mpm_event
a2enmod mpm_prefork
nano /etc/php/7.1/cli/php.ini
date.time = Asia/Kolkata

Configure MariaDB

By default, MariaDB installation is not secured. So you will need to secure it first. You can secure it by running the following script:

mysql_secure_installation
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
mysql -u root -p
MariaDB [(none)]> CREATE DATABASE librenmsdb;
MariaDB [(none)]> CREATE USER 'librenmsuser'@'localhost' IDENTIFIED BY 'password';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON librenmsdb.* TO 'librenmsuser'@'localhost';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> exit;

Download LibreNMS

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
cd /opt/
git clone https://github.com/librenms/librenms.git librenms
./scripts/composer_wrapper.php install --no-dev
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:

nano /etc/apache2/sites-available/librenms.conf
<VirtualHost *:80>
DocumentRoot /opt/librenms/html/
ServerName example.com
CustomLog /opt/librenms/logs/access_log combined
ErrorLog /opt/librenms/logs/error_log
AllowEncodedSlashes NoDecode
<Directory "/opt/librenms/html/">
Require all granted
AllowOverride All
Options FollowSymLinks MultiViews
</Directory>
</VirtualHost>
a2ensite librenms.conf
a2enmod rewrite
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:

cd /opt/librenms
cp librenms.nonroot.cron /etc/cron.d/librenms
cp misc/librenms.logrotate /etc/logrotate.d/librenms
systemctl restart cron
logrotate -f /etc/logrotate.conf
/opt/librenms/validate.php
====================================
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

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.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alibaba Cloud

Alibaba Cloud

4.97K Followers

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com