How To Install Nagios on CentOS 9 Stream

Install Nagios on CentOS 9 Stream

In this tutorial, we will show you how to install Nagios on CentOS 9 Stream. For those of you who didn’t know, Nagios Core, formerly known as Nagios, is a free and open-source computer-software application that monitors systems, networks, and infrastructure. It supports both Linux and Windows OS and provides an intuitive web interface that allows you to easily monitor network resources.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Nagios core monitoring tool on CentOS 9 Stream.


  • A server running one of the following operating systems: CentOS 9 Stream.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Nagios on CentOS 9 Stream

Step 1. First, let’s start by ensuring your system is up-to-date.

sudo dnf clean all
sudo dnf update
sudo dnf install httpd httpd-tools php gcc glibc glibc-common gd gd-devel make net-snmp

Step 2. Create User and Group for Nagios.

Run the following command below to create a user and group Nagios:

useradd nagios
groupadd nagcmd

After that, add both the Nagios and the apache users to the nagcmd group:

usermod -G nagcmd nagios
usermod -G nagcmd apache

Step 3. Installing Nagios on CentOS 9 Stream.

By default, Nagios is not available on the CentOS 9 Stream base repository. Let’s download the latest version of Nagios and Nagios plugins from the official page using the following command below:

wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.6.tar.gz
wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz

Next, extract Nagios and Nagios Plugins:

tar -xvf nagios-4.4.6.tar.gz
tar -xvf nagios-plugins-2.2.1.tar.gz

After that, we compile the Nagios from the source code:

cd nagios-4.4.6/
./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-commandmode
make install-config

Once is complete, now we compile and install Nagios Plugin libraries using the following command below:

cd /root/nagios
cd nagios-plugins-2.2.1/

Run Nagios Plugin configuration file:

./configure --with-nagios-user=nagios --with-nagios-group=nagios
make all
make install

Verify Nagios configuration files:

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

Finally, enable Nagios services:

sudo systemctl enable nagios
sudo systemctl enable httpd

Step 4. Configure Nagios.

Nagios places configuration files under the /usr/local/nagios/etc directory. Now we edit email alerts and configure the file /usr/local/nagios/etc/objects/contacts.cfg:

nano /usr/local/nagios/etc/objects/contacts.cfg

Replace the email address field to receive the notification:

define contact {
contact_name            nagiosadmin             ; Short name of user
use                     generic-contact         ; Inherit default values from generic-contact template (defined above)
alias                   Nagios Admin            ; Full name of user
email                   admin@idroot.us ;       <--- **** CHANGE THIS TO YOUR EMAIL ADDRESS ****

Step 5. Configure Web Interface for Nagios.

First, run the following command to install the web interface:

make install-webconf

Next, we set a password for the web interface:

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

Once you are done with the configuration, start Apache services:

sudo systemctl start httpd

Step 3. Configure Firewall.

Allow the firewall to port HTTP and HTTPS  and reload it with the following commands:

sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
sudo firewall-cmd --zone=public --add-port=443/tcp --permanent
sudo firewall-cmd --reload

Step 6. Accessing Nagios Web Interface.

Once successfully installed, open your web browser and access the Nagios Core using the URL http://your-IP-server/nagios. You will need to use the username (nagiosadmin) and password you specified earlier to access the Nagios web interface:

Install Nagios on CentOS 9 Stream

You will be redirected to the following page:

Install Nagios on CentOS 9 Stream

Congratulations! You have successfully installed Nagios. Thanks for using this tutorial to install Nagios Core on CentOS 9 Stream. For additional help or useful information, we recommend you check the official Nagios website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!


r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button