Installing and Setting Up Nagios on CentOS Stream 9: A Practical Guide

In this guide, we’ll go through the steps needed to install and configure Nagios on CentOS Stream 9. Nagios is a widely used open-source monitoring tool that helps system administrators monitor network devices, services, and host resources. The Nagios installation on CentOS Stream 9 is as follows :
Table of Contents
- Introduction
- Prerequisites
- Step 1: Update the System
- Step 2: Install Essential Packages
- Step 3: Create Nagios User and Group
- Step 4: Install Nagios Core
- Step 5: Install Nagios Plugins
- Step 6: Configure the Web Interface
- Step 7: Start and Enable Services
- Step 8: Open Firewall Ports
- Step 9: Access the Nagios Dashboard
- Step 10: Verify Your Setup
- Conclusion
Nagios is a powerful, open-source IT infrastructure monitoring system widely used to monitor networks, servers, applications, and services. It’s particularly popular among system administrators for its extensive features, flexibility, and reliability, making it ideal for large-scale IT environments where maintaining uptime and performance is crucial.
1. Introduction
Nagios Core is a robust, open-source monitoring solution that keeps tabs on your servers, services, and network devices. In this guide, you’ll walk through installing Nagios Core on CentOS Stream 9, configuring its web interface, and opening necessary firewall ports for access.
2. Prerequisites
Before beginning, make sure you have:
- A server running CentOS Stream 9
- A user account with sudo privileges (avoid root)
- Basic familiarity with the Linux command line
3. Step 1: Update the System
Kick off with a fresh update to ensure your software packages are current:
sudo dnf update -y
4. Step 2: Install Essential Packages
Nagios Core requires HTTPD, PHP, and development tools. Install them with:
sudo dnf install -y httpd php gcc glibc glibc-common wget unzip
You may also add packages like gd
, perl
, or others depending on your setup.
5. Step 3: Create Nagios User and Group
Nagios needs its own user and command group for security and execution:
sudo useradd nagios
sudo groupadd nagcmd
sudo usermod -aG nagcmd nagios
sudo usermod -aG nagcmd apache
6. Step 4: Install Nagios Core
Download and extract the latest Nagios Core:
cd /tmp
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.6.tar.gz
tar zxvf nagios-4.4.6.tar.gz
cd nagios-4.4.6
Now compile and install:
./configure --with-command-group=nagcmd
make all
sudo make install
sudo make install-init
sudo make install-config
sudo make install-commandmode
7. Step 5: Install Nagios Plugins
Plugins are essential for monitoring. Set them up with:
cd /tmp
wget https://nagios-plugins.org/download/nagios-plugins-2.4.6.tar.gz
tar zxvf nagios-plugins-2.4.6.tar.gz
cd nagios-plugins-2.4.6
./configure --with-nagios-user=nagios --with-nagios-group=nagcmd
make
sudo make install
8. Step 6: Configure the Web Interface
Set up access to Nagios’ web UI:
sudo make install-webconf
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Provide a password when prompted—you’ll use these credentials later.
9. Step 7: Start and Enable Services
Enable and launch Nagios and Apache on boot:
sudo systemctl enable nagios
sudo systemctl start nagios
sudo systemctl enable httpd
sudo systemctl start httpd
10. Step 8: Open Firewall Ports
Allow HTTP traffic so you can access Nagios remotely:
sudo firewall-cmd --permanent --add-port=80/tcp
sudo firewall-cmd --reload
11. Step 9: Access the Nagios Dashboard
Point your browser to:
http://<your-server-IP>/nagios
Log in using:
- Username:
nagiosadmin
- Password: the one you created earlier
You should now see Nagios’ main monitoring interface.
12. Step 10: Verify Your Setup
Check the health and status of your hosts and services. If everything appears, congratulations! Your Nagios Server is up and running.
13. Conclusion
You’ve now completed the installation of Nagios Core on CentOS Stream 9. From updating your system to logging into the Nagios dashboard, this guide has covered the essentials. You’re now ready to expand your monitoring setup with additional hosts, services, and alerting features.