How to Setup and Configure Nagios Core on CentOS 7

Nagios Core is a free and open source software that monitors systems, networks and infrastructure. You can monitor and configure alerts for servers, switches, application, services, logs. In this tutorial, you will learn how to setup and configure Nagios Core 4.4.5 on CentOS 7.


  • Before starting nagios installation, You need to disable SELinux.
$  sudo setenforce 0

Or modify /etc/selinux/config file and change enforcing to disabled. After modifications please restart your machine to enable changes.

$ sudo vim /etc/selinux/config

Step:1. Install Build Dependencies

Now you need to install the dependencies that Core will need in order to function properly.

$ sudo yum install gcc glibc glibc-common wget gd gd-devel perl net-snmp openssl-devel curl unzip -y

Step:2. Download Nagios Core and Nagios Plugin

You need to create a directory for nagios installation. Now we will download the required nagios source code using below command.

$ mkdir /nagios

$ cd /nagios
$ sudo curl -L -O
$ sudo curl -L -O

Step:3. Create Nagios User and Group

You must create a user and group that will responsible to run the Nagios process. Please create ‘nagios’ user and ‘nagcmd’ group, then add the user to this group using below commands,

$ sudo useradd nagios

$ sudo groupadd nagcmd
$ sudo usermod -a -G nagcmd nagios
$ sudo usermod -a -G nagcmd apache

Step:4. Configuring Nagios Core and Customize Nagios Configuration

Here, first we will configure nagios core, so we will move into nagios directory and extract downloaded packages with tar command as follows. Therefore we will configure nagios core as follows and you can see the end result in sample output snip.

$  cd /nagios

$ tar -xvf nagios-4.4.5.tar.gz
$ cd /nagios/nagios-4.4.5
$ ./configure --with-command-group=nagcmd

In below snip, there is end result of above command. The above command is executed successfully without errors or warning.

After configuring, you need to compile all binaries with below command.

$  make all

After compiling, you need to install all binaries using make install command. It will install all required libraries.

$  make install

End Result of the above command

The below command will install the init scripts for nagios. And to make sure nagios work from command line, you need to install command mode.

$  make install-init
$  make install-commandmode

Below commands install sample nagios files.

$   make install-config

To receive email alerts on your mail id, Open the “contacts.cfg” file and put the email address.

$ sudo vim /usr/local/nagios/etc/objects/contacts.cfg

Step:5. Configure Web Interface for Nagios

We finished all configuration changes and now we are good to configure web interface for better monitoring. The following command “make install-webconf” will configure web interface and a user nagiosadmin. You now need to create a password for the nagiosadmin user. This user will be used to login to your nagios web console.

$  make install-webconf
$ sudo htpasswd -s -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password: xxxxxxxxx
Re-type new password: xxxxxxxxx
Adding password for user nagiosadmin

Step:6. Install & Configure Nagios Plugin

As we have already downloaded nagios plugin, let’s configure and install it using below commands.

$  cd /nagios

$ tar -xvf nagios-plugins-2.2.1.tar.gz
$ cd /nagios/nagios-plugins-2.2.1
$ ./configure --with-nagios-user=nagios --with-nagios-group=nagios
$ make all

$ make install

Step:7. Verify Nagios Configuration Files

So we have completed all necessary steps to configure nagios. Now let’s verify whether we have done all steps correctly. Please cross verify your output by below sample output.

$ sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

We now are good to start the nagios and httpd service.

$ sudo systemctl start httpd.service 

$ sudo systemctl start nagios.service

Step:8. Login to the Nagios Web Console

Well done, you have successfully installed and configured Nagios. Now you can open in your web browser using “http://your_server_IP_address/nagios” then provide username “nagiosadmin” and password. The screen must be looking as below and nagios process should be running.


Hence, you have successfully installed and configured Nagios Core on CentOS 7. I hope I helped. Happy Learning, Thanks !!

Read Also : Difference Between File Systems in Linux

Share on:

Ravindra Kumar

Hi, This is Ravindra. I am founder of TheCodeCloud. I am AWS Certified Solutions Architect Associate & Certified in Oracle Cloud as well. I am DevOps and Data Science Enthusiast.

Recommended Reading..

Leave a Comment