Install Nagios on Centos 5
Installing Nagios server and network monitoring on Centos 5 server
The official documentation can be found at http://support.nagios.com/knowledge-base/official-documentation
Install necessary packages
yum install httpd gcc glibc glibc-common gd gd-devel php
Create Nagios User account and group
useradd -m nagios
Create nagcmd group for allowing external commands to be submitted through the web interface. Add both the nagios user and the apache user
groupadd nagcmd usermod -a -G nagcmd nagios usermod -a -G nagcmd apache
Create Directory to store Nagios installation files
mkdir /opt/Nagios
Download Nagios and Plugins
Save file to directory /opt/Nagios
http://www.nagios.org/download/download.php
As of this writing Nagios 3.0.6 (Stable) and Nagios Plugins 1.4.13 (Stable)
Extract Files:
cd /opt/Nagios tar xzf nagios-3.0.6.tar.gz cd nagios-3.0.6
Compile and Configure Nagios
./configure --with-command-group=nagcmd
Compile Nagios:
make all
Compile binaries, init script, sample config files:
make install make install-init make install-config make install-commandmode
** Do Not Start Nagios **
Nagios has now been installed to the directory /usr/local/nagios/
Install Nagios Web Interface:
make install-webconf
Nagios Web Interface installed to /usr/local/nagios/share ( http conf file added to /etc/httpd/conf.d/nagios.conf )
Create Web Interface Login User:
** This is not the most secure method **
We will create user “nagiosadmin” ( remember the password you assign !)
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Restart Apache:
service httpd restart
Install Nagios Plugins
Extract Files:
cd /opt/Nagios tar xzf nagios-plugins-1.4.13.tar.gz cd nagios-plugins1.4.13
Compile and Configure Nagios Plugins
./configure --with-nagios-user=nagios --with-nagios-group=nagios make make install
Configure nagiosadmin email address for alerts
vi /usr/local/nagios/etc/objects/contacts.cfg email nagios@localhost ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
Verify the sample Nagios configuration files
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg Total Warnings: 0 Total Errors: 0
Start Nagios
Enable Nagios to start at system startup / boot
chkconfig --add nagios chkconfig nagios on chkconfig httpd on
Start Nagios
service nagios start
Log into Web Interface
http://ip-address/nagios/



Great writeup! One additional would be to include php in your yum install line.
Thanks!
Thank Travis
Added php to yum install line
Hi
I do all you wrote, i get no errors but when i try to logging to the Nagios using the web i get 401 error , i use the user and pass i cretaed in the start.
any ideas?
401 is authorization error
issue with /usr/local/nagios/etc/htpasswd.users
Check permissions of htpasswd.users and also try again
htpasswd -c /usr/local/nagios/etc/htpasswd.users
It seems it is working so no it is time to play xD
Thanks a lot!!
How can i add host on nagios.. Here another problem when i browse like this http://10.156.0.36/nagios…that time when i click on host i saw an error.whats the reason
I got the same 401 error but I could navigate to the left pane menu.
to fix it i did
#su -l
#passwd nagios (reset the nagios password)
#getenforce
#setenforce 0
#chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/
#chcon -R -t httpd_sys_content_t /usr/local/nagios/share/
I was able to see the content in the right frame.
Hope this helps.
ciao
Nino
Thanks a lot………it is perfect document ..thank u one again..
[...] you want to install Nagios on Centos 5.4? Then this great tutorial is the way to do it. Worked great for me in my practice [...]
Dear Fabio,
I have my system centos5.4 and i did all nagios configuration with no errors. But i have the problem in viewing in pages using the ip address like http://X.X.X.X/nagios/, i get the message like “Failed to connect”….May i know what sort of error is this?
My configurations for nagios are as per your steps.
Expecting a quick response.
usayg
Need more information
Are you trying to connect from the machine that has Nagios installed or from another remote machine ?
If remote machine do you have your firewall open to accept port 80 (web connections)
You could add wget to the yum install line and then instead of downloading and putting in /opt/Nagios just put:
cd /opt/Nagios
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-x.x.x.tar.gz
wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-x.x.x.tar.gz
and continue from there.
worked like a charm. learning how to use it, thanks for making it easy to install it…
Thanks Fabio. This was an outstanding tutorial.