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

wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.3.4.tar.gz

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

wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz

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
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

http://hostname/nagios

  • username: nagiosadmin
  • password: password