Install LibreNMS on Ubuntu with HTTPS

The goal of this guide is to install LibreNMS on an Ubuntu Server with a self signed certificate.  Most of the steps are copied out of the LibreNMS Documentation found here.

Install required packages

sudo apt install apache2 composer fping git graphviz imagemagick libapache2-mod-php7.0 mariadb-client mariadb-server mtr-tiny nmap 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 python-memcache python-mysqldb rrdtool snmp snmpd whois

Create LibreNMS user

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

Install LibreNMS

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

Configure MySQL

sudo systemctl restart mysql
sudo mysql -uroot -p

Run the following MySQL commands to create the LibreNMS user. Change password to your own password.

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

Edit following file

sudo vi /etc/mysql/mariadb.conf.d/50-server.cnf

Add the following inside the [mysqld] section

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

Restart MySQL

sudo systemctl restart mysql

Configure PHP

Edit the two files and set the time zone, date.timezone.  Example “America/New_York”

sudo vi /etc/php/7.0/apache2/php.ini
sudo vi /etc/php/7.0/cli/php.ini

Then run these commands

sudo a2enmod php7.0
sudo a2dismod mpm_event
sudo a2enmod mpm_prefork
sudo phpenmod mcrypt

Generate Self signed certificate

Enable ssl in apache

sudo a2enmod ssl

Generate Cert

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/localhost.key -out /etc/ssl/certs/localhost.crt

Configure Apache

Edit the following config file

sudo vi /etc/apache2/sites-available/librenms.conf

Add the following

<VirtualHost *:443>
 DocumentRoot /opt/librenms/html/
 ServerName librenms.example.com
 SSLEngine on
 SSLCertificateFile /etc/ssl/certs/localhost.crt
 SSLCertificateKeyFile /etc/ssl/private/localhost.key
 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>

Run the following commands

sudo a2ensite librenms.conf
sudo a2enmod rewrite
sudo systemctl restart apache2

Configure snmpd

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

Set the SNMP community string in the following file

sudo vi /etc/snmp/snmpd.conf

Then run these commands

sudo curl -o /usr/bin/distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro
sudo chmod +x /usr/bin/distro
sudo systemctl restart snmpd

Setup Crontab

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

Copy logrotate config

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

Set permissions

mkdir -p /opt/librenms/rrd /opt/librenms/logs
sudo chown -R librenms:librenms /opt/librenms
sudo setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs
sudo setfacl -R -m g::rwx /opt/librenms/rrd /opt/librenms/logs

Web Installer

Restart apache

sudo systemctl restart apache2

Finish the install by going to

https://your-server/install.php

Change “your-server” to your server’s ip address, or hostname.  Since we created a self signed certificate, you’ll need to accept the https error.

Validate

Back on the command line run the php validation script

sudo /opt/librenms/validate.php

Finally log into your new LibreNMS instance by going to

https://your-server

Change “your-server” to your server’s IP address or hostname.

Ubuntu 16.04 Login Screen Issues

This post is not meant to be a how to, but rather a compilation commands that could be helpful in trying to fix issues with the login screen after an upgrade.

These commands should be executed from a prompt, you can get to one using the ctrl+alt+f1 (you can replace f1 with any of the function keys from 1-7), or you can boot up from recovery, or you could mount the drive and chroot into it.

Reinstall Desktop and Login Manager

sudo apt-get install --reinstall lightdm ubuntu-desktop

If your using using Gnome Shell

sudo apt-get install --reinstall gdm3 gnome-shell

Reconfigure lightdm, set it as the default login manager

sudo dpkg-reconfigure lightdm

Replace GDM with LightDM

sudo apt-get remove gdm3 
sudo apt-get install lightdm

Installing GDM (Gnome Login Manager)

sudo apt-get install gdm3

Remove Intel video and Plymouth

sudo apt-get remove xserver-xorg-video-intel plymouth

Reboot, get to a prompt and reinstall login manager, replace lightdm with whatever one your using

sudo apt-get install --reinstall lightdm

Reinstall Intel video and Plymouth

sudo apt-get install xserver-xorg-video-intel plymouth

Install Ubuntu Gnome Desktop

This seems to solve some of the issues with GDM3 not starting up.

sudo apt-get install ubuntu-gnome-desktop

 

How to Install Flash on Linux

Installing flash on Ubuntu is pretty straight forward.  Type the following command into a terminal and press enter and away you go.

sudo apt-get install flashplugin-installer

On Fedora need to do the following

(64-bit)

sudo yum install http://linuxdownload.adobe.com/adobe-release/adobe-release-x86_64-1.0-1.noarch.rpm -y

(32-bit)

sudo yum install http://linuxdownload.adobe.com/adobe-release/adobe-release-i386-1.0-1.noarch.rpm -y

And install the Adobe Flash web browser plugin.  The first command imports the GPG key for the Adobe Flash plugin repository and the second command installs the plugin itself.

sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-adobe-linux 
sudo yum install flash-plugin -y

How to set a Static IP Address in Ubuntu and Debian

The first thing we need to do, is open our interfaces file.  Execute the following from a terminal.

sudo vi /etc/network/interfaces

or

sudo nano /etc/network/interfaces

Then add or copy and paste the following.

auto eth0
iface eth0 inet static
        address 192.168.1.100
        netmask 255.255.255.0
        network 192.168.1.0
        broadcast 192.168.1.255
        gateway 192.168.1.1

Close the file. Now we need to change the DNS settings

sudo vi /etc/resolv.conf

or

sudo nano /etc/resolv.conf

Edit the nameserver line to something like the following.

nameserver 8.8.8.8

Close the file and then restart the networking stuff.

sudo /etc/init.d/networking restart