Want full control over your server monitoring? Learn how to install Nagios on CentOS 7 and start tracking system health like a pro—before performance issues catch you off guard. Don’t miss out on building a rock-solid monitoring setup trusted by IT experts worldwide! #centlinux #linux #nagios
Table of Contents
What is Nagios?
Nagios Core is a free and open source software application that provides monitoring and alerting services for servers, switches, applications and services. It monitors targets (i.e. hosts and services) and alerts users when something go wrong and alerts them a second time when the problem has been resolved. Nagios Core is primary application and monitoring and alerting engine, around that hundred of Nagios Projects are built.

In this article, we will install Nagios on CentOS 7. But before moving forward, it is required to have basic concepts of Nagios Core 4. Therefore, it is highly recommended that you should attend:
Recommended Training: Nagios | Ultimate IT monitoring guide with EyesOfNetwork from Tech Academy

System Specification
We have configured a CentOS 7 virtual machine with following specifications:
- Operating System – CentOS 7.6
- Nagios Core – 4.4.2
- Hostname – nagios-01.example.com
- IP Address: – 192.168.116.130/24
NYXI Flexi Wireless Controller, 1000Hz Polling Rate Hall Effect Joystick, Interchangeable D-pad&Left Joystick, 4 Mppable Buttons, 800mAh Battery, Adjustable Turbo/Vibration for PC/Switch/iOS/Android
$59.99 (as of May 14, 2025 16:10 GMT +00:00 – More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Install Nagios on CentOS 7
Connect to nagios-01.example.com using ssh.
Install prerequisite packages using yum command.
yum install -y gcc glibc glibc-common wget unzip httpd php gd gd-devel perl postfix
Currently, Nagios Core does not compliance with SELinux, therefore we have to disable SELinux.
sed -i 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
setenforce 0
Create a directory for downloading Nagios Core source.
mkdir setup
Download Nagios Core from https://www.nagios.org/downloads/nagios-core/.
cd ~/setup
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.2.tar.gz
Extract downloaded source of Nagios Core.
tar xf nagios-4.4.2.tar.gz
Compile and install Nagios Core from extracted source.
cd ~/setup/nagios-4.4.2
./configure
Output:
config.status: creating t/Makefile
config.status: creating t-tap/Makefile
config.status: creating include/config.h
config.status: creating lib/snprintf.h
config.status: creating lib/iobroker.h
Creating sample config files in sample-config/ ...
*** Configuration summary for nagios 4.4.2 2018-08-16 ***:
General Options:
-------------------------
Nagios executable: nagios
Nagios user/group: nagios,nagios
Command user/group: nagios,nagios
Event Broker: yes
Install ${prefix}: /usr/local/nagios
Install ${includedir}: /usr/local/nagios/include/nagios
Lock file: /run/nagios.lock
Check result directory: /usr/local/nagios/var/spool/checkresults
Init directory: /lib/systemd/system
Apache conf.d directory: /etc/httpd/conf.d
Mail program: /usr/sbin/sendmail
Host OS: linux-gnu
IOBroker Method: epoll
Web Interface Options:
------------------------
HTML URL: http://localhost/nagios/
CGI URL: http://localhost/nagios/cgi-bin/
Traceroute (used by WAP):
Review the options above for accuracy. If they look okay,
type 'make all' to compile the main program and CGIs.
Execute following command to compile Nagios Source.
make all
Output:
...
make[1]: Entering directory `/root/setup/nagios-4.4.2/worker'
cd ./ping && make all
make[2]: Entering directory `/root/setup/nagios-4.4.2/worker/ping'
gcc -I.. -I ../../include -I ../.. -g -O2 -DHAVE_CONFIG_H -o worker-ping worker-ping.c -L ../../lib -l nagios
make[2]: Leaving directory `/root/setup/nagios-4.4.2/worker/ping'
make[1]: Leaving directory `/root/setup/nagios-4.4.2/worker'
*** Compile finished ***
If the main program and CGIs compiled without any errors, you
can continue with testing or installing Nagios as follows (type
'make' without any arguments for a list of all possible options):
make test
- This runs the test suite
make install
- This installs the main program, CGIs, and HTML files
make install-init
- This installs the init script in /lib/systemd/system
make install-daemoninit
- This will initialize the init script
in /lib/systemd/system
make install-groups-users
- This adds the users and groups if they do not exist
make install-commandmode
- This installs and configures permissions on the
directory for holding the external command file
make install-config
- This installs *SAMPLE* config files in /usr/local/nagios/etc
You'll have to modify these sample files before you can
use Nagios. Read the HTML documentation for more info
on doing this. Pay particular attention to the docs on
object configuration files, as they determine what/how
things get monitored!
make install-webconf
- This installs the Apache config file for the Nagios
web interface
make install-exfoliation
- This installs the Exfoliation theme for the Nagios
web interface
make install-classicui
- This installs the classic theme for the Nagios
web interface
*** Support Notes *******************************************
If you have questions about configuring or running Nagios,
please make sure that you:
- Look at the sample config files
- Read the documentation on the Nagios Library at:
https://library.nagios.com
before you post a question to one of the mailing lists.
Also make sure to include pertinent information that could
help others help you. This might include:
- What version of Nagios you are using
- What version of the plugins you are using
- Relevant snippets from your config files
- Relevant error messages from the Nagios log file
For more information on obtaining support for Nagios, visit:
https://support.nagios.com
*************************************************************
Enjoy.
Create OS user and groups for Nagios Core.
make install-groups-users
Output:
groupadd -r nagios
useradd -g nagios nagios
Add nagios user to apache group.
usermod -a -G nagios apache
Install Nagios on CentOS 7 now.
make install
Output:
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/libexec
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/var
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/var/archives
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/var/spool/checkresults
chmod g+s /usr/local/nagios/var/spool/checkresults
*** Main program, CGIs and HTML files installed ***
You can continue with installing Nagios as follows (type 'make'
without any arguments for a list of all possible options):
make install-init
- This installs the init script in /lib/systemd/system
make install-commandmode
- This installs and configures permissions on the
directory for holding the external command file
make install-config
- This installs sample config files in /usr/local/nagios/etc
make[1]: Leaving directory `/root/setup/nagios-4.4.2'
Install Nagios Core service.
make install-daemoninit
Output:
/usr/bin/install -c -m 755 -d -o root -g root /lib/systemd/system
/usr/bin/install -c -m 755 -o root -g root startup/default-service /lib/systemd/system/nagios.service
Created symlink from /etc/systemd/system/multi-user.target.wants/nagios.service to /usr/lib/systemd/system/nagios.service.
*** Init script installed ***
Enable httpd service.
systemctl enable httpd.service
Install and configure external command file.
make install-commandmode
Output:
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/var/rw
chmod g+s /usr/local/nagios/var/rw
*** External command directory configured ***
Install Sample configuration files for Nagios Core.
# make install-config /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/windows.cfg /usr/local/nagios/etc/objects/windows.cfg /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/printer.cfg /usr/local/nagios/etc/objects/printer.cfg /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/switch.cfg /usr/local/nagios/etc/objects/switch.cfg *** Config files installed *** Remember, these are *SAMPLE* config files. You'll need to read the documentation for more information on how to actually define services, hosts, etc. to fit your particular needs.
Add Nagios Core configurations to Apache Web Server.
make install-webconf
Output:
/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf
if [ 0 -eq 1 ]; then
ln -s /etc/httpd/conf.d/nagios.conf /etc/apache2/sites-enabled/nagios.conf;
fi
*** Nagios/Apache conf file installed ***
TP-Link AXE5400 Tri-Band WiFi 6E Router (Archer AXE75)- Gigabit Wireless Internet Router, ax Router for Gaming, VPN Router, OneMesh, WPA3, Black
$129.99 (as of May 14, 2025 16:10 GMT +00:00 – More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Configure Linux Firewall
Configure Linux Firewall to allow http service.
firewall-cmd --permanent --add-service=http
firewall-cmd --reload
Setup Basic HTTP Authentication
Nagios does not have integrated user authentication, therefore, we have to use Basic HTTP authentication for this purpose.
Create an admin user for Nagios Core Web UI.
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Start httpd & nagios services.
systemctl daemon-reload
systemctl start httpd.service
systemctl start nagios.service
Access Nagios Web Interface
Browse URL http://192.168.116.130/nagios to connect with Nagios Core Web UI.

Login using nagiosadmin user.

Go to services page.

You can see that all the services are unavailable. It is because we don’t have installed Nagios Plugins on our CentOS 7 server.
Install Nagios Plugins on CentOS 7
Install prerequisite packages for Nagios Plugins using yum command.
yum install -y perl-Net-SNMP gcc glibc glibc-common make gettext automake autoconf wget openssl-devel net-snmp net-snmp-utils epel-release
Download Nagios Plugins from https://www.nagios.org/downloads/nagios-plugins/.
cd ~/setup
wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz
Extract downloaded source of Nagios Plugins.
cd ~/setup
tar xf nagios-plugins-2.2.1.tar.gz
Compile Nagios Plugins source.
cd ~/setup/nagios-plugins-2.2.1
./configure
Output:
...
config.status: executing libtool commands
config.status: executing po-directories commands
config.status: creating po/POTFILES
config.status: creating po/Makefile
Install Nagios Plugins by executing following command.
make
make install
Go to Nagios Web UI and open services page.

You can see that, now all the services are in OK state now. (Note: Keep patience, Nagios Core takes a while to collect data for each service)
Kali Linux for Beginners, A step-by-step Guide to Ethical Hacking: Mastering Cybersecurity with Hands-On Exercises
$1.99 (as of May 14, 2025 16:10 GMT +00:00 – More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Final Thoughts
By installing Nagios on CentOS 7, you’ve taken the first crucial step toward proactive server monitoring and issue detection. With its powerful alerting and visualization capabilities, Nagios helps you stay in control of your infrastructure—before problems impact your users.
Don’t fall behind relying on guesswork or outdated tools; now’s the time to automate your monitoring and gain real-time visibility. Thousands of sysadmins trust Nagios—make sure you’re not the one left troubleshooting in the dark.
Need a dependable Linux system administrator? I specialize in managing, optimizing, and securing Linux servers to keep your operations running flawlessly. Check out my services on Fiverr!
Leave a Reply
You must be logged in to post a comment.