Nagios Core is an open-source infrastructure monitoring system that tracks servers, switches, applications, and services. It alerts you when things go wrong and again when they recover. For teams running RHEL-based infrastructure, Nagios remains one of the most reliable monitoring solutions available – lightweight, extensible through plugins, and battle-tested across millions of deployments.
This guide walks through installing Nagios Core 4.5.11 from source on RHEL 10 or Rocky Linux 10, including the Nagios Plugins, Apache web interface, host/service monitoring, email notifications, and firewall configuration.
Prerequisites
Before starting, make sure you have the following in place:
- A server running RHEL 10, Rocky Linux 10, or AlmaLinux 10 with at least 2 GB RAM
- Root or sudo access
- A working DNS name or static IP for the Nagios server
- Internet access to download source packages
- Ports 80 (HTTP) and 443 (HTTPS) open in the firewall
- An SMTP-capable mail setup for alert notifications (Postfix or external relay)
Switch to the root user for the rest of this guide:
sudo -i
Step 1: Install Nagios Core Dependencies
Nagios Core is compiled from source, so we need development tools plus libraries for the web interface and plugins. Install all required packages in one command:
dnf install -y gcc glibc glibc-common make gettext automake autoconf wget \
openssl-devel net-snmp net-snmp-utils epel-release \
perl-Net-SNMP postfix unzip httpd php php-fpm gd gd-devel \
perl perl-devel
Enable and start Apache and PHP-FPM so the web interface is ready once Nagios is installed:
systemctl enable --now httpd php-fpm
Step 2: Create Nagios User and Group
Nagios runs under its own dedicated user. The nagcmd group allows the web interface to issue external commands (acknowledge alerts, schedule downtime, etc.):
useradd nagios
groupadd nagcmd
usermod -aG nagcmd nagios
usermod -aG nagcmd apache
Step 3: Download and Compile Nagios Core
Download the latest Nagios Core 4.5.11 source tarball and extract it:
cd /tmp
wget https://github.com/NagiosEnterprises/nagioscore/releases/download/nagios-4.5.11/nagios-4.5.11.tar.gz
tar xzf nagios-4.5.11.tar.gz
cd nagios-4.5.11
Run the configure script, specifying the command group we created earlier:
./configure --with-command-group=nagcmd
The configure summary should show all checks passed. Now compile and install Nagios along with its init scripts, command mode, and sample configuration:
make all
make install
make install-init
make install-commandmode
make install-config
Install the Apache configuration file for the Nagios web interface:
make install-webconf
Step 4: Set Up the Nagios Web Interface Password
Create the nagiosadmin user for web interface authentication. Replace the password when prompted:
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
You will be prompted to enter and confirm a password. This is the login you use to access the Nagios dashboard.
Restart Apache to pick up the new Nagios configuration:
systemctl restart httpd
Step 5: Install Nagios Plugins
Nagios Core by itself has no monitoring capability – it relies on Nagios Plugins to perform the actual checks. Download and compile the latest plugins release (2.4.12):
cd /tmp
wget https://github.com/nagios-plugins/nagios-plugins/releases/download/release-2.4.12/nagios-plugins-2.4.12.tar.gz
tar xzf nagios-plugins-2.4.12.tar.gz
cd nagios-plugins-2.4.12
Configure and compile the plugins:
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
After installation, the plugins are placed in /usr/local/nagios/libexec/. Verify they exist:
ls /usr/local/nagios/libexec/ | head -20
You should see a list of check plugins like check_ping, check_http, check_disk, and many more.
Step 6: Configure Apache Web Interface for Nagios
The make install-webconf step already created /etc/httpd/conf.d/nagios.conf. Verify it exists and review the key settings:
cat /etc/httpd/conf.d/nagios.conf
The default configuration maps /nagios to the Nagios web directory and requires authentication. The key directives are:
ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
<Directory "/usr/local/nagios/sbin">
Options ExecCGI
AllowOverride None
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
</Directory>
Alias /nagios "/usr/local/nagios/share"
<Directory "/usr/local/nagios/share">
Options None
AllowOverride None
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
</Directory>
If you need to change the web path or add SSL, edit this file. For now, the defaults work for initial setup. If SELinux is in enforcing mode, allow Apache to connect to the Nagios CGI scripts:
setsebool -P httpd_can_network_connect 1
Step 7: Configure Nagios Core (nagios.cfg)
The main Nagios configuration file is /usr/local/nagios/etc/nagios.cfg. The sample config installed earlier works out of the box, but there are a few settings worth reviewing. Open the file:
vi /usr/local/nagios/etc/nagios.cfg
Key settings to verify or adjust:
# Where object config files are loaded from
cfg_dir=/usr/local/nagios/etc/servers
# Log file location
log_file=/usr/local/nagios/var/nagios.log
# External commands (needed for web UI actions like ack/downtime)
check_external_commands=1
# How often Nagios checks for external commands (seconds)
command_check_interval=-1
# Admin email and pager for notifications
[email protected]
[email protected]
The cfg_dir line tells Nagios to load all .cfg files from the /usr/local/nagios/etc/servers/ directory. Create this directory now – we will add host definitions there:
mkdir -p /usr/local/nagios/etc/servers
Verify the configuration is valid before starting Nagios:
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
The output should end with “Things look okay” and zero errors. If you see warnings or errors, fix the referenced config files before proceeding.
Step 8: Add Hosts and Services to Monitor
Nagios monitors targets through host and service object definitions. Each remote host gets its own config file in /usr/local/nagios/etc/servers/. Here is an example for a web server at 10.0.1.50. Create the file:
vi /usr/local/nagios/etc/servers/webserver01.cfg
Add the following host and service definitions:
define host {
use linux-server
host_name webserver01
alias Web Server 01
address 10.0.1.50
max_check_attempts 5
check_period 24x7
notification_interval 30
notification_period 24x7
}
define service {
use generic-service
host_name webserver01
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
define service {
use generic-service
host_name webserver01
service_description HTTP
check_command check_http
}
define service {
use generic-service
host_name webserver01
service_description SSH
check_command check_ssh
}
define service {
use generic-service
host_name webserver01
service_description Disk Usage
check_command check_local_disk!20%!10%!/
}
This defines the host and four services: ping connectivity, HTTP response, SSH availability, and local disk usage. The check_ping thresholds mean warning at 100ms/20% loss and critical at 500ms/60% loss.
For monitoring remote Linux hosts with detailed checks (CPU, memory, disk), install NRPE on the target server. See our guide on adding remote hosts to Nagios for monitoring for the full NRPE setup.
After adding host files, validate the configuration again:
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Step 9: Configure Email Notifications
Nagios sends alert emails through the local mail system. Make sure Postfix is installed and running:
systemctl enable --now postfix
Nagios notification commands are defined in /usr/local/nagios/etc/objects/commands.cfg. The default commands use /usr/bin/mail to send host and service alerts. Open the contacts configuration:
vi /usr/local/nagios/etc/objects/contacts.cfg
Update the nagiosadmin contact with your real email address:
define contact {
contact_name nagiosadmin
use generic-contact
alias Nagios Admin
email [email protected]
}
define contactgroup {
contactgroup_name admins
alias Nagios Administrators
members nagiosadmin
}
Replace [email protected] with the address where you want to receive alerts. You can add multiple contacts by creating additional define contact blocks and adding them to the admins group.
Test email delivery from the command line to confirm Postfix is working:
echo "Nagios test email" | mail -s "Nagios Alert Test" [email protected]
If you are using an external SMTP relay (Gmail, Amazon SES, etc.), configure Postfix as a relay host in /etc/postfix/main.cf instead of sending directly.
Step 10: Configure Firewall for Nagios
Open HTTP and HTTPS ports in firewalld so you can access the Nagios web interface:
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --reload
Confirm the rules are active:
firewall-cmd --list-services
The output should include http and https in the list of allowed services. If you are running Nagios behind a reverse proxy or on a non-standard port, adjust accordingly.
If you also plan to use NRPE for remote host checks, open TCP port 5666 on the remote hosts (not the Nagios server).
Step 11: Start Nagios and Verify the Monitoring Dashboard
Enable and start the Nagios service:
systemctl enable --now nagios
Check that Nagios is running:
systemctl status nagios
The output should show active (running) with no errors. If the service fails to start, check /usr/local/nagios/var/nagios.log for details.
Open your browser and navigate to:
http://your-server-ip/nagios
Log in with the nagiosadmin credentials you created in Step 4. The dashboard shows the Tactical Overview with host and service status summaries. Click “Hosts” in the left menu to see monitored hosts, and “Services” for individual service checks.
Give Nagios a few minutes to run the initial round of checks. Hosts and services will transition from “PENDING” to their actual status (OK, WARNING, CRITICAL, or UNKNOWN).
Nagios Configuration Files Reference
Nagios has several configuration files spread across its installation directory. This table summarizes the key files you will work with:
| File Path | Purpose |
|---|---|
/usr/local/nagios/etc/nagios.cfg | Main configuration file – controls global settings, loaded config dirs, logging |
/usr/local/nagios/etc/cgi.cfg | Web interface CGI settings – controls who can view/modify what in the dashboard |
/usr/local/nagios/etc/objects/commands.cfg | Check and notification command definitions |
/usr/local/nagios/etc/objects/contacts.cfg | Contact and contactgroup definitions for notifications |
/usr/local/nagios/etc/objects/timeperiods.cfg | Time period definitions (24×7, workhours, etc.) |
/usr/local/nagios/etc/objects/templates.cfg | Host and service templates (linux-server, generic-service, etc.) |
/usr/local/nagios/etc/servers/ | Directory for your custom host/service definitions |
/usr/local/nagios/etc/htpasswd.users | Web interface user authentication file |
/etc/httpd/conf.d/nagios.conf | Apache configuration for the Nagios web UI |
/usr/local/nagios/var/nagios.log | Main Nagios log file for troubleshooting |
Conclusion
You now have Nagios Core 4.5.11 running on RHEL 10 or Rocky Linux 10 with the web interface, plugins, host monitoring, and email notifications configured. The next steps for a production deployment include enabling HTTPS with a Let’s Encrypt certificate, setting up NRPE on remote hosts for detailed system checks, and configuring escalation policies so critical alerts reach the right people at the right time.
For scaling your monitoring setup, consider these related guides: install Nagios Server on Rocky Linux 10 / AlmaLinux 10, top open source monitoring tools for comparing alternatives, and monitoring with Prometheus and Grafana if you need metrics-based monitoring alongside Nagios alerting.