Nagios Core is a widely-used open-source infrastructure monitoring system that alerts administrators to host and service failures. On RHEL 9, Nagios Core must be compiled from source since no official RPM package is maintained for the current release. This guide walks you through building Nagios Core 4.x, installing the standard plugins, securing the web interface with Apache and htpasswd, and verifying your first monitored host. By the end you will have a functional Nagios installation accessible through a browser.

Prerequisites

  • RHEL 9 server with a sudo or root account
  • A registered RHEL 9 subscription or access to the AppStream and BaseOS repositories
  • Apache HTTP Server (httpd) installed or available to install
  • Internet access to download source tarballs from nagios.org
  • Basic familiarity with compiling software from source on Linux

Step 1 — Install Build Dependencies

Nagios Core requires a C compiler, the Apache development libraries, the GD graphics library, and OpenSSL development headers to compile successfully. Install all required packages with a single dnf command.

sudo dnf install -y gcc glibc glibc-common perl gd gd-devel make net-snmp openssl-devel unzip wget httpd php php-cli php-pdo gettext autoconf automake

# Enable the CodeReady Linux Builder (CRB) repo for additional -devel packages
sudo subscription-manager repos --enable codeready-builder-for-rhel-9-$(arch)-rpms
# or for AlmaLinux / Rocky Linux 9:
# sudo dnf config-manager --set-enabled crb

sudo dnf install -y libpng-devel libjpeg-devel

Step 2 — Create the Nagios User and Group

Nagios runs its daemon under a dedicated system account. You also add the Apache user (apache) to the nagios group so the web interface can read status files written by the daemon.

sudo useradd -m -s /bin/bash nagios
sudo groupadd nagcmd

sudo usermod -aG nagcmd nagios
sudo usermod -aG nagcmd apache

Step 3 — Download and Compile Nagios Core

Download the latest Nagios Core 4.x source tarball, extract it, and run the standard configure / make / make install sequence. The --with-nagios-group flag assigns file ownership to the group created above.

cd /tmp
NAGIOS_VER="4.5.3"
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-${NAGIOS_VER}.tar.gz
tar xzf nagios-${NAGIOS_VER}.tar.gz
cd nagios-${NAGIOS_VER}

./configure --with-nagios-group=nagios --with-command-group=nagcmd 
            --with-httpd-conf=/etc/httpd/conf.d

make all
sudo make install
sudo make install-init
sudo make install-daemoninit
sudo make install-config
sudo make install-commandmode
sudo make install-webconf

Step 4 — Install Nagios Plugins

The Nagios Core daemon performs no checks itself — all service checks are delegated to external plugins. Install the official Nagios Plugins package from the EPEL repository to gain over 50 standard check scripts.

# Enable EPEL if not already present
sudo dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm

sudo dnf install -y nagios-plugins-all

# Alternatively compile from source:
# wget https://nagios-plugins.org/download/nagios-plugins-2.4.6.tar.gz
# tar xzf nagios-plugins-2.4.6.tar.gz && cd nagios-plugins-2.4.6
# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
# make && sudo make install

Step 5 — Secure the Web Interface and Open the Firewall

Nagios ships with an Apache virtual host configuration installed by make install-webconf. Create an htpasswd file to protect the CGI dashboard, then open port 80 in firewalld.

# Create the Nagios admin password file
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
# Enter a strong password when prompted

# Start and enable Apache
sudo systemctl enable --now httpd

# Open HTTP in the firewall
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload

# Adjust SELinux to allow the CGI scripts to execute
sudo setsebool -P httpd_enable_cgi 1
sudo chcon -R -t httpd_sys_script_exec_t /usr/local/nagios/sbin/

Step 6 — Configure Nagios and Start the Service

The main configuration file is /usr/local/nagios/etc/nagios.cfg. Update contacts.cfg with your email address, verify the configuration syntax, and then start the Nagios daemon. After startup, open a browser to the host’s IP address and log in as nagiosadmin.

# Set the admin email in contacts.cfg
sudo sed -i 's/nagios@localhost/[email protected]/' 
    /usr/local/nagios/etc/objects/contacts.cfg

# Verify the configuration
sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

# Enable and start the daemon
sudo systemctl enable --now nagios

# Check the service status
sudo systemctl status nagios

# View the Nagios web UI
# http:///nagios
# Login: nagiosadmin / 

Conclusion

You have compiled Nagios Core 4.x from source on RHEL 9, installed the standard plugin suite, secured the web interface with Apache Basic Authentication, and verified that the daemon is actively monitoring localhost. The default configuration already checks CPU load, disk usage, swap, and SSH on the local machine. From the Nagios web UI you can browse host and service states, acknowledge problems, and schedule downtime. To extend coverage, add host and service definitions in /usr/local/nagios/etc/objects/ and send Nagios a SIGHUP to reload the configuration without a full restart.

Next steps: How to Monitor MySQL with Percona Monitoring and Management on RHEL 9, How to Set Up OpenTelemetry Collector on RHEL 9, and How to Configure syslog-ng for Centralised Syslog on RHEL 9.