Librenms Installation on Arch Linux!



This guide extends on the official Librenms Installation page by adding in the commands for setting up Librenms on Arch Linux as the official documentation only has Debian/Centos based distro setups included. Please refer to the original documentation at https://docs.librenms.org/Installation/Install-LibreNMS/ for non Arch install guides.



# pacman -S bash-completion composer cronie fping apache imagemagick git mariadb mtr net-snmp nmap php-fpm php php-gd php-snmp python python-pymysql python-redis python-memcached
                 python-mysqlclient python-pip rrdtool unzip whois


# nano /etc/php/php.ini

Enable These Extensions by removing the ‘;’ before the Extension Name & Set Timezone in php.ini:

extension=gd
extension=mysqli
extension=pdo_mysql
extension=snmp
extension=sockets


date.timezone = Australia/Brisbane


# mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

# systemctl enable mariadb

# systemctl start mariadb


# useradd librenms -d /opt/librenms -M -r -s /usr/bin/bash


# cd /opt

# git clone https://github.com/librenms/librenms.git


# chown -R librenms:librenms /opt/librenms

# chmod 771 /opt/librenms

# setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/

# setfacl -R -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/

# su - librenms

# ./scripts/composer_wrapper.php install --no-dev

# exit

# nano /etc/my.cnf.d/server.cnf

##Within the [mysqld] section add:

innodb_file_per_table=1

lower_case_table_names=0

Restart MariaDB Server :

# systemctl restart mariadb


Add Librenms Database Schema :

# mysql -u root

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


Enable Apache Proxy Modules By Removing The '#' In Front Of The Following :

# nano /etc/httpd/conf/httpd.conf

LoadModule proxy_module modules/mod_proxy.so

LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so

Loadmodule rewrite_module modules/mod_rewrite.so


Create /etc/httpd/conf/extra/php-fpm.conf with the following content :

# nano /etc/httpd/conf/extra/php-fpm.conf

DirectoryIndex index.php index.html

<FilesMatch \.php$>

SetHandler "proxy:unix:/run/php-fpm/php-fpm.sock|fcgi://localhost/"

</FilesMatch>

Include generic php-fpm.conf configuration to the bottom of /etc/httpd/conf/httpd.conf :

# nano /etc/httpd/conf/httpd.conf

Include conf/extra/php-fpm.conf


Include Librenms specific php-fpm configuration :

# cp /etc/php/php-fpm.d/www.conf /etc/php/php-fpm.d/librenms.conf

# nano /etc/php/php-fpm.d/librenms.conf

Change "www" to "librenms"

[librenms]

Change user and group to "librenms"

user = librenms

group = librenms

Change listen to a unique name

listen = /run/php-fpm-librenms.sock



# nano /etc/httpd/conf/librenms.conf

<VirtualHost *:80>

DocumentRoot /opt/librenms/html/

ServerName librenms.example.com

AllowEncodedSlashes NoDecode

<Directory "/opt/librenms/html/">

Require all granted

AllowOverride All

Options FollowSymLinks MultiViews

</Directory>

# Enable http authorization headers

<IfModule setenvif_module>

SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1

</IfModule>

<FilesMatch ".+\.php$">

SetHandler "proxy:unix:/run/php-fpm-librenms.sock|fcgi://localhost"

</FilesMatch>

</VirtualHost>

Include Librenms HTTP Configuration into Apache Global Configuration :

# nano /etc/httpd/conf/httpd.conf

Include conf/librenms.conf


Enable & Start HTTPD & PHP-FPM Services :

# systemctl enable httpd

# systemctl start httpd

# systemctl enable php-fpm

# systemctl start php-fpm



# mkdir /etc/snmp

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

# nano /etc/snmp/snmpd.conf

##Edit the text which says RANDOMSTRINGGOESHERE and set your own community string – For Example: public

# curl -o /usr/bin/distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro

# chmod +x /usr/bin/distro

# systemctl enable snmpd

# systemctl start snmpd


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

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

# systemctl enable cronie

# systemctl start cronie



Now head to the web installer and follow the on-screen instructions to finish the installation.

http://localhost/install or http://librenms.yourhostname.com/install


The web installer might prompt you to create a config.php file in your librenms install location manually, copying the content displayed on-screen to the file. If you have to do this, please remember to set the permissions on config.php after you copied the on-screen contents to the file. Run:

# chown librenms:librenms /opt/librenms/config.php


If you ever have issues with your install, run validate.php:

# sudo su - librenms
  ./validate.php


If you encounter issues, go check the log files which normally will point you in the right direction:

/opt/librenms/logs/librenms.log

/var/log/httpd/error_log

Final steps

That's it! You now should be able to log in to http://librenms.example.com/. Please note that we have not covered HTTPS setup in this example, so your LibreNMS install is not secure by default. Please do not expose it to the public Internet unless you have configured HTTPS and taken appropriate web server hardening steps.

Add the first device

We now suggest that you add localhost as your first device from within the WebUI.


======================================================

APPENDIX A - Compiling the latest Fping from source

Arch Fping binary package version is currently 4.3-1 which is out of date - you need version 5 of fping so perform the following to compile fping from source manually :

# wget https://fping.org/dist/fping-5.0.tar.gz

# tar xvf fping-5.0.tar.gz

# cd fping-5.0

# ./configure

# make

# make install

# cd src

# mv fping /usr/bin

=====================================================