Prerequisites:
1. Apache 2
2. PHP
3. GCC Compiler and development libraries
4. GD development libraries.
Install these packages from internet by apt-get command.
#apt-get install apache2
#apt-get install libapache2-mod-php5
#apt-get install build-essential
#apt-get install libgd2-xpm-dev
Or by only one command:
#apt-get install apache2 libapache2-mod-php5 build-essential libgd2-xpm-dev
Create account Information:
You have to create one user (nagios)and two groups (nagios, nagcmd). Nagcmd group will be use for allowing external commands to be submitted through the web interface. And nagios user will be member of nagios and nagcmd group. Apache user(www-data) will also be a member of nagcmd group.
#adduser nagios
Then set password for this user. No need to create nagios group externally. By default it will be created and nagios user will be a member of this group.
#groupadd nagcmd
#usermod -a -G nagcmd nagios
#usermod -a -G nagcmd www-data
Download Nagios and Plugins packages:
Here I have installed nagios core 3.2.3 version and plugins 1.4.11 version.
Download both packages in any directory .
#wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.3.tar.gz
#wget http://prodownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.11.tar.gz
Compile and Install Nagios:
Extract the nagios source code and enter extracted directory.
#tar zxvf nagios-3.2.3.tar.gz
#cd nagios-3.2.3
Run the Nagios configure script and passing the name of the nagcmd group then compile Nagios source code.
#./configure –with-command-group=nagcmd
#make all
Install binaries, init scrip, sample config file and set permissions on the external command directory.
#make install
#make install-init
#make install-config
#make install-commandmode
Nagios will be install in the /usr/local/ directory.
Configure web Interface:
Install the nagios web config file in the Apache conf.d directory.
#make install-webconf
Create nagiosadmin account for logging into the Nagios web interface and assign password.
#htpasswd –c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Customize Contact information:
Edit /usr/local/nagios/etc/objects/contacts.cfg config file and replace your e-mail address by any editor.
Restart Apache to make new settings take effect.
#/etc/init.d/apache2 reload
Compile and Install the Nagios plugins:
Extract the nagios-plugins source code and enter extracted directory
#tar zxvf nagios-plugins-1.4.11.tar.gz
#cd nagios-plugins-1.4.11
Compile and install plugins:
Run the Nagios-plugins configure script and passing the user and group name nagios then compile Nagios-plugins source code.
#./configure --with-nagios-user=nagios --with-nagios-group=nagios
#make
#make install
Start Nagios:
Configure nagios to automatically start when the system boots.
#ln –s /etc/init.d/nagios /etc/rcS.d/S99nagios
Verify the Nagios configuration file:
#/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
If no error found then it will shows :
Total Warnings: 0
Total Errors: 0
If there are no errors, Start Nagios.
#/etc/init.d/nagios start
Login to the web interface: