Skip to main content

How to Install Nagios 4.4.1 on RHEL/CentOS

Nagios is the most popular open source monitoring tool. It monitors your servers/services and alerts staff if a problem arises and reduces the downtime and business losses. So, in this article, I will guide you on how to install Nagios 4.4.1 on your RHEL 7.x/6.x/5.x or CentOS 7.x/6.x/5.x distributions.

Step 1: Install Required Dependencies

The packages such as Apache PHP, gcc, glibc, glibc-common and GD libraries are required to install Nagios. So, we will install all the dependencies before we begin the installation of Nagios 4.4.1.

[[email protected] ~]# yum install httpd httpd-tools php gcc glibc glibc-common gd gd-devel make net-snmp perl postfix -y

Step 2: Setup Nagios User and Group

Now, we need to create a new nagios user and group account. Here, I’m using the username asnagios” and group name as “nagiosgrp”.

[[email protected] ~]# useradd nagios
[[email protected] ~]# groupadd nagcmd

Next, add both the nagios user and the apache user to the nagcmd group.

[[email protected] ~]# usermod -G nagcmd nagios
[[email protected] ~]# usermod -G nagcmd apache

Step 3: Install Nagios Core Service and plugin

[[email protected] ~]# mkdir /usr/localsrc/nagios
[[email protected] ~]# cd /usr/local/src/nagios

Download the latest Nagios Core 4.4.1 and Nagios plugins 2.2.1 packages.

[[email protected] nagios]# wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.1.tar.gz
[[email protected] nagios]# wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz

Extract the downloaded packages.

[[email protected] nagios]# tar -zxvf nagios-4.4.1.tar.gz
[[email protected] nagios]# tar -zxvf nagios-plugins-2.2.1.tar.gz

Next, configure and install Nagios Core.

[[email protected] nagios]# cd nagios-4.4.1/
[[email protected] nagios-4.4.1]# ./configure --with-command-group=nagcmd
[[email protected] nagios-4.4.1]# make all
[[email protected] nagios-4.4.1]# make install
[[email protected] nagios-4.4.1]# make install-init
[[email protected] nagios-4.4.1]# make install-commandmode
[[email protected] nagios-4.4.1]# make install-config
[[email protected] nagios-4.4.1]# make install-webconf

Step 4: Securing Nagios Apache Web interface

It is important to secure the Nagios Apache Web Interface. So, we can create a new user “nagioswebadmin” and assign it a password. Please note down this password you provide here, as it will be used to login to the Nagios Web interface.

[[email protected] nagios-4.4.1]# htpasswd -s -c /usr/local/nagios/etc/htpasswd.users nagioswebadmin
New password:
Re-type new password:
Adding password for user nagioswebadmin

Restart Apache to make the new changes take effect.

[[email protected] nagios-4.4.1]# service httpd start   # On RHEL/CentOS 5.x/6.x
[[email protected] nagios-4.4.1]# systemctl start httpd # On RHEL/CentOS 7.x

Step 5: Compile and Install Nagios Plugin

Now, go to “/usr/local/src/nagios/nagios-plugins-2.2.1/” directory and install the Nagios plugin.

[[email protected]]# cd /usr/local/src/nagios/nagios-plugins-2.2.1/
[[email protected] nagios-plugins-2.2.1]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
[[email protected] nagios-plugins-2.2.1]# make
[[email protected] nagios-plugins-2.2.1]# make install

Step 6: Verify and Start Nagios

You can verify the Nagios installation by running the following command.

[[email protected] nagios-plugins-2.2.1]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
[[email protected] nagios-plugins-2.2.1]# service nagios start   # On RHEL/CentOS 5.x/6.x
[[email protected] nagios-plugins-2.2.1]# systemctl start nagios # On RHEL/CentOS 7.x
[[email protected] nagios-plugins-2.2.1]# chkconfig --add nagios
[[email protected] nagios-plugins-2.2.1]# chkconfig nagios on

Nagios will start if you haven’t made any mistakes during the installation process.

Step 7: Accessing the Nagios Web Interface

You can now access the Nagios Web Interface by opening the URL “http://Your-server-IP-address/nagios” or “http://Your-Server-Hostname/nagios” on the Web Browser. Enter the username “nagioswebadmin” and password which you have setup in the Step 4.

The Nagios Home Page

 

Nagios Hosts Page

 

 

The main Nagios configuration file is “/usr/local/nagios/etc/nagios.cfg”.

That’s it for now. We will discuss how to add a remote host to Nagios monitoring Server in coming posts. If you have any questions or face any trouble during the installation process, please feel free to leave a comment below.

Rate this post

Vipin Haridas

Vipin Haridas is a Linux and Open Source enthusiast who loves to share knowledge on the Internet.