How to install Nagios 4 from Source on Centos 6

Install required packages

yum install httpd php gcc glibc glibc-common gd gd-devel make net-snmp unzip

Add Users and Groups

useradd nagios

groupadd nagcmd

usermod -a -G nagcmd nagios

usermod -a -G nagios,nagcmd apache

Compile and Install Nagios

cd /tmp


tar zxvf nagios-4.3.4.tar.gz

cd nagios-4.3.4

./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-commandmode
make install-config
make install-webconf
cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
rm -rf /tmp/nagios-4.3.4

Set the password

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

Compile and Install Nagios Plugins

cd /tmp


tar zxvf nagios-plugins-2.2.1.tar.gz

cd nagios-plugins-2.2.1

./configure --with-nagios-user=nagios --with-nagios-group=nagios
make install
rm -rf /tmp/nagios-plugins-2.2.1

Verify the configuration

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

Configure Nagios & Apache services

chkconfig --add nagios

chkconfig nagios on

/etc/init.d/nagios start

chkconfig httpd on

/etc/init.d/httpd start

Login to the Nagios Web Interface


  • username: nagiosadmin
  • password: password

Update Nagios

service nagios stop
cd /tmp
tar zxvf nagios-4.4.2.tar.gz
cd nagios-4.4.2
make all 
make install
make install-daemoninit
service nagios start