CentOSLinuxTutorials

How To Install LibreNMS on CentOS 8

Install LibreNMS on CentOS 8

In this tutorial, we will show you how to install LibreNMS on CentOS 8. For those of you who didn’t know, LibreNMS is an open-source auto-discovering network monitoring tool for servers and network hardware. It supports a wide range of network hardware like Cisco, Juniper, Brocade, Foundry, HP, and operating systems including Linux and Windows. LibraNMS is a community-based fork of the Network monitoring tool “Observium“, released under GPLv3.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the LibreNMS network monitoring tool on CentOS 8.

Prerequisites

  • A server running one of the following operating systems: CentOS 8.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install LibreNMS on CentOS 8

Step 1. First, let’s start by ensuring your system is up-to-date and installing all required dependencies.

sudo dnf install epel-release
sudo dnf update

Step 2. Installing the LEMP stack.

A CentOS LAMP server is required. If you do not have LEMP installed, you can follow our guide here.

Step 3. Installing LibreNMS on CentOS 8.

Now we clone LibreNMS software from GitHub like below:

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

We will need to change some folders permissions:

chown -R librenms:librenms /opt/librenms
chmod 770 /opt/librenms
setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/ /opt/librenms/cache
setfacl -R -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/ /opt/librenms/cache

Step 4. Run Composer Wrapper.

Run the following commands to run the composer wrapper script:

cd /opt/librenms
curl -sS https://getcomposer.org/installer | php
su - librenms
./scripts/composer_wrapper.php install --no-dev

Step 5. Configuring MariaDB for LibreNMS.

By default, MariaDB is not hardened. You can secure MariaDB using the mysql_secure_installation script. you should read and below each step carefully which will set a root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MariaDB:

mysql_secure_installation

Configure it like this:

- Set root password? [Y/n] y
- Remove anonymous users? [Y/n] y
- Disallow root login remotely? [Y/n] y
- Remove test database and access to it? [Y/n] y
- Reload privilege tables now? [Y/n] y

Next, we will need to log in to the MariaDB console and create a database for the LibreNMS. Run the following command:

mysql -u root -p

This will prompt you for a password, so enter your MariaDB root password and hit Enter. Once you are logged in to your database server you need to create a database for LibreNMS installation:

MariaDB [(none)]> CREATE DATABASE librenms CHARACTER SET utf8 COLLATE utf8_unicode_ci;
MariaDB [(none)]> CREATE USER 'librenms'@'localhost' IDENTIFIED BY 'YOUR-PASSWD';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'localhost';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> exit

Once done, open the MariaDB configuration file and add the following lines under [mysqld] section:

nano /etc/my.cnf

Within the [mysqld] section please add:

innodb_file_per_table=1 
lower_case_table_names=0

Then, restart MariaDB for the changes to take effect:

sudo systemctl restart mariadb

Step 6. Configure PHP.

Now we edit php.ini to your preferred time zone:

nano /etc/php.ini

Add the following line:

date.timezone = Asia/Jakarta

Step 5. Configuring Nginx for LibreNMS.

Let’s create the VirtualHost definition for Nginx to be used by LibreNMS:

/etc/nginx/conf.d/librenms.conf

Add the following to the config file:

server {
 listen      80;
 server_name librenms.idroot.us;
 root        /opt/librenms/html;
 index       index.php;

 charset utf-8;
 gzip on;
 gzip_types text/css application/javascript text/javascript application/x-javascript image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon;
 location / {
  try_files $uri $uri/ /index.php?$query_string;
 }
 location /api/v0 {
  try_files $uri $uri/ /api_v0.php?$query_string;
 }
 location ~ \.php {
  include fastcgi.conf;
  fastcgi_split_path_info ^(.+\.php)(/.+)$;
  fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
 }
 location ~ /\.ht {
  deny all;
 }
}

Now, we can restart the Nginx web server so that the changes take place:

sudo systemctl restart nginx

Step 6. Configure Firewall.

Allow Nginx through the firewall so that the user can able to access the LibreNMS portal from an external machine:

sudo firewall-cmd --zone public --add-service http
sudo firewall-cmd --permanent --zone public --add-service http
sudo firewall-cmd --reload

Step 7. Accessing LibreNMS Web Interface on the CentOS system.

LibreNMS will be available on HTTP port 80 by default. Open your favorite browser and navigate to http://your-domain.com/install.php or http://server-ip-address/install.php and complete the required steps to finish the installation.

Install LibreNMS on CentOS 8

Congratulations! You have successfully installed LibreNMS. Thanks for using this tutorial for installing the LibreNMS network monitoring tool on your CentOS 8 system. For additional help or useful information, we recommend you to check the official LibreNMS website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button