How to Install and Configure Nagios Core on CentOS 8 / RHEL 8

Nagios is a free and opensource network and alerting engine used to monitor various devices, such as network devices, and servers in a network. It supports both Linux and Windows OS and provides an intuitive web interface that allows you to easily monitor network resources. When professionally configured, it can alert you in the event a server or a network device goes down or malfunctions via email alerts. In this topic, we shed light on how you can install and configure Nagios core on RHEL 8 / CentOS 8.


Prerequisites of Nagios Core

Before we begin, perform a flight check and ensure you have the following:

  • An instance of RHEL 8 / CentOS 8
  • SSH access to the instance
  • A fast and stable internet connection

With the above requirements in check, let’s roll our sleeves!

Step 1: Install LAMP Stack

For Nagios to work as expected, you need to install LAMP stack or any other web hosting stack since it’s going to run on a browser. To achieve this, execute the command:

# dnf install httpd mariadb-server php-mysqlnd php-fpm


You need to ensure that Apache web server is up and running. To do so, start and enable Apache server using the commands:

# systemctl start httpd
# systemctl enable httpd


To check the status of Apache server run

# systemctl status httpd


Next, we need to start and enable MariaDB server, run the following commands

# systemctl start mariadb
# systemctl enable mariadb


To check MariaDB status run:

# systemctl status mariadb


Also, you might consider hardening or securing your server and making it less susceptible to unauthorized access. To secure your server, run the command:

# mysql_secure_installation

Be sure to set a strong password for your MySQL instance. For the subsequent prompts, Type Yes and hit ENTER


Step 2: Install Required packages

Apart from installing the LAMP server, some additional packages are needed for the installation and proper configuration of Nagios. Therefore, install the packages as shown below:

# dnf install gcc glibc glibc-common wget gd gd-devel perl postfix


Step 3: Create a Nagios user account

Next, we need to create a user account for the Nagios user. To achieve this , run the command:

# adduser nagios
# passwd nagios


Now, we need to create a group for Nagios and add the Nagios user to this group.

# groupadd nagiosxi

Now add the Nagios user to the group

# usermod -aG nagiosxi nagios

Also, add Apache user to the Nagios group

# usermod -aG nagiosxi apache


Step 4: Download and install Nagios core

We can now proceed and install Nagios Core. The latest stable version in Nagios 4.4.5 which was released on August 19, 2019.  But first, download the Nagios tarball file from its official site.

To download Nagios core, first head to the tmp directory

# cd /tmp

Next download the tarball file

# wget


After downloading the tarball file, extract it using the command:

# tar -xvf nagios-4.4.5.tar.gz

Next, navigate to the uncompressed folder

# cd nagios-4.4.5

Run the commands below in this order

# ./configure --with-command-group=nagcmd
# make all
# make install
# make install-init
# make install-daemoninit
# make install-config
# make install-commandmode
# make install-exfoliation

To setup Apache configuration issue the command:

# make install-webconf

Step 5: Configure Apache Web Server Authentication

Next, we are going to setup authentication for the user nagiosadmin. Please be mindful not to change the username or else, you may be required to perform further configuration which may be quite tedious.

To set up authentication run the command:

# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin


You will be prompted for the password of the nagiosadmin user. Enter and confirm the password as requested. This is the user that you will use to login to Nagios towards the end of this tutorial.

For the changes to come into effect, restart your web server.

# systemctl restart httpd

Step 6: Download & install Nagios Plugins

Plugins will extend the functionality of the Nagios Server. They will help you monitor various services, network devices, and applications. To download the plugin tarball file run the command:

# wget

Next, extract the tarball file and navigate to the uncompressed plugin folder

# tar -xvf nagios-plugins-2.2.1.tar.gz
# cd nagios-plugins-2.2.1

To install the plugins compile the source code as shown

# ./configure --with-nagios-user=nagios --with-nagios-group=nagiosxi
# make
# make install

Step 7: Verify and Start Nagios

After the successful installation of Nagios plugins, verify the Nagios configuration to ensure that all is well and there is no error in the configuration:

# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg


Next, start Nagios and verify its status

# systemctl start nagios
# systemctl status nagios


In case Firewall is running on system then allow “80” using the following command

# firewall-cmd --permanent --add-port=80/tcp
# firewall-cmd --reload

Step 8: Access Nagios dashboard via the web browser

To access Nagios, browse your server’s IP address as shown


A pop-up will appear prompting for the username and the password of the user we created earlier in Step 5. Enter the credentials and hit ‘Sign In


This ushers you to the Nagios dashboard as shown below


We have finally successfully installed and configured Nagios Core on CentOS 8 / RHEL 8. Your feedback is most welcome.

Also Read : How to Add Windows and Linux host to Nagios Server for Monitoring

Also Read :  How to Setup Multi Node Elastic Stack Cluster on RHEL 8 / CentOS 8

Share on:

James Kiarie, a certified Linux administrator and a passionate tech enthusiast who stays connected with the latest trends in the tech world. Beyond executing commands on the terminal, you'll find me enjoying some cool music, taking casual strolls, or indulging in a good movie.

12 thoughts on “How to Install and Configure Nagios Core on CentOS 8 / RHEL 8”

  1. Thank you for posting.
    It worked for me. I had one small issue near the end:
    ./configure –with-command-group=nagcmd #nagcmd generated make errors
    ./configure –with-command-group=nagiosxi #I substituted nagiosxi for nagcmd

  2. Hi – great guide – worked first time, but with one tweak. These lines seemed inconsistent…?

    usermod -aG nagiosxi nagios
    ./configure –with-command-group=nagcmd

    I think the second line should be:

    ./configure –with-command-group=nagiosxi

    The second line worked for me and nagios now up and running…

  3. It works, I checked it. However, I see no reason to install nagios from source codes, you can easily install the EPEL repo and get everithyng installed with a couple of commands.
    Moreover, there is no need to install mariadb, nagios doesn’t use it.

  4. FYI, in “Step 7: Verify and Start Nagios” when running “systemctl start nagios”, I got:

    Failed to start nagios.service: Unit nagios.service not found.

    I had to add a file:

    … in order to get things working

  5. Hello, thanks for your contribution.

    I have a problem, I installed everything but when I go to the http: // server-ip / nagios browser, the page does not appear. should I configure something else?

  6. Hey Jhon Robinson, If you are accessing the Nagios server from a different machine , please check the firewall configuration and ensure that you have opened port 80 on the Nagios server.

  7. thank you so much..
    only one error *./configure –with-command-group=nagcmd
    replace above line with ./configure –with-command-group=nagiosxi

  8. How to monitor HCI nodes installed with VMWare ESXi hypervisors ( As there no OS on the host machine, how we can use nagios?/for any failing nodes of any HCI servers?


Leave a Comment