How to install Nagios on Ubuntu

What is Nagios?

Nagios® is a system and network monitoring application. It watches hosts and services that you specify, alerting you when things go bad and when they get better. Nagios was originally designed to run under Linux, although it should work under most other unices as well.

Some of the many features of Nagios® include:

  • Monitoring of network services (SMTP, POP3, HTTP, NNTP, PING, etc.).
  • Monitoring of host resources (processor load, disk usage, etc.).
  • Simple plugin design that allows users to easily develop their own service checks.
  • Parallelized service checks.
  • Ability to define network host hierarchy using “parent” hosts, allowing detection of and distinction between hosts that are down and those that are unreachable.
  • Contact notifications when service or host problems occur and get resolved (via email, pager, or user-defined method).
  • Ability to define event handlers to be run during service or host events for proactive problem resolution.
  • Automatic log file rotation.
  • Support for implementing redundant monitoring hosts.
  • Optional web interface for viewing current network status, notification and problem history, log file, etc.

System Requirements

The following software packages is required to run Nagios server.

  • Apache 2
  • GCC compiler and development libraries
  • GD development libraries

Steps to install Nagios

Become a super user

user@server:~# sudo su -

Install the GCC compiler and GD libraries

root@server:~# apt-get install build-essential libgd2-dev

Create “nagios” user and “nagios” group

root@server:~# useradd -d /opt/nagios -m nagios
root@server:~# groupadd nagios

Now we add Apache user (www-data) and Nagios user (nagios) to Nagios group (nagios)

root@server:~# usermod -G nagios nagios
root@server:~# usermod -G nagios www-data

Download latest source code tarball of Nagios from You may create a directory to store this files.

root@server:~# mkdir ~/downloads
root@server:~# cd ~/downloads
root@server:~# wget 

Extract the Nagios tar file.

root@server:~# tar zxfv nagios-.tar.gz
root@server:~# cd nagios-

Run the Nagios configure script.

root@server:~# ./configure --prefix=/opt/nagios --with-cgiurl=/nagios/cgi-bin --with-htmurl=/nagios --with-command-group=nagios

If the previous command comes back without reporting any errors you can run the following commands. If errors are reported, fix them and run “make clean” before running the previous command again.

root@server:~# make all
root@server:~# make install
root@server:~# make install-init
root@server:~# make install-config
root@server:~# make install-commandmode
root@server:~# make install-webconfig

Create nagiosadmin account for logging into Nagios web interface.

root@server:~# htpasswd -c /opt/nagios/etc/htpasswd.users nagiosadmin

Now you may reload Apache’s configuration to make new settings take effect.

root@server:~# /etc/init.d/apache2 reload

Nagios plugin installation

Download latest source code tarball of Nagios plugin from

root@server:~# cd ~/downloads
root@server:~# wget

Extract the Nagios plugin tar file.

root@server:~# tar zxfv nagios-plugin-.tar.gz
root@server:~# cd nagios-plugin-

Run the Nagios plugin configure script.

root@server:~# ./configure --prefix=/opt/nagios --with-cgiurl=/nagios/cgi-bin --with-htmurl=/nagios --with-command-group=nagios

Now compile and install it.

root@server:~# make
root@server:~# make install

Verify and start the Nagios
Verify the Nagios configuration files.

root@server:~# /opt/nagios/bin/nagios -v /opt/nagios/etc/nagios.cfg

If no errors, you can start the Nagios server.

root@server:~# /etc/init.d/nagios start