Jan 022008

The procedures listed here will help you successfully install Nagios 2.x on a Linux platform. The procedure listed here is been tested on Debian 3.1 (Sarge) and Redhat Enterprise Linux.

  • Operating System : Debian 3.1 (Sarge) and Redhat Enterprise Linux.
  • Webserver : Apache 2
  • Nagios : 2.3.1 (Stable)

Lets start with downloading Nagios. Nagios can be downloaded from



Create a User Account that Nagios runs as (Default: Nagios)

# useradd nagios

 This should create the user account and a default group with the same name (nagios). This can be checked by

# grep nagios /etc/passwd

This should show the group (if created) with the members.

If the group is missing then create the group by,

# groupadd nagios

This group can be used as the group that  Nagios uses as a Command group.

Add the Nagios user and the user which the webserver (Apache) runs as

 In Debian, the user is www-data

In Redhat, this is apache.

You can also check this from the config file of the webser by using one th following:


# grep “^User” /etc/apache2/apache2.conf


# ps -ef | grep apache (if Apache is running)


# grep “^User” /etc/httpd/conf.d/httpd.conf


# ps -ef | grep apache (if Apache is running)

Add webserver user (www-data/apache) and Nagios user (nagios)

# usermod -G nagios nagios
#usermod -G www-data,nagios www-data (Debian)
#usermod -G apache,nagios apache (Redhat)

Check i the users are the members of the group by

# grep nagios /etc/group

 Create the Nagios root directory

The default folder is /usr/local/nagios

# mkdir /usr/local/nagios

All is done and we are ready to install

Download Nagios

# wget http://prdownloads.sourceforge.net/nagios/nagios-2.3.1.tar.gz?download

# tar -zxvf nagios -version.tar.gz (for example nagios-2.3.1.tar.gz)

This will create the Nagios-version folder (nagios-2.3.1)

Change directory to the newly created directory

# cd nagios-version (nagios-2.3.1)

Run the configure script

# ./configure –prefix=/usr/local/nagios –with-cgiurl=/nagios/cgi-bin –with-htmurl=/nagios/ –with-nagios-user=nagios –with-nagios-group=nagios –with-command-group=nagios


–prefix=/usr/local/nagios is the Nagios root folder
–with-cgiurl=/nagios/cgi-bin is the Nagios CGI folder
–with-htmurl=/nagios/ is the Nagios HTML/Website folder
–with-nagios-user=nagios is the Nagios user
–with-nagios-group=nagios is the Nagios group
–with-command-group=nagios is the Nagios command group which has webserver user (Apache) and the nagios user as members.

Install the base software and HTML files

# make && make install

Install the init scripts

# make install-init

Create the required directory for command file and assign appropriate permissions to it for the external commands.

# make install-commandmode

Install the sample configs.

# make install-config

This is optional but is a very good starting point to get your nagios going.

Rename the sample config files installed in the /usr/local/nagios/etc directory from .cfg-sample to .cfg format.

# mv bigger.cfg-sample bigger.cfg

Similary rename all the files in the folder.

Now, you have a completely installed nagios to work on. The next steps would be to install the plugins and start configuring Nagios.

Prior to that, it is imporant to install the GD-Utils for the Status Maps to work properly.

In Debian, the following should install the required libraries:

# apt-get install libgd2-xpm libgd2-xpm-dev libgd2 libgd2-dev libpng12-dev libjpeg62-dev libgd-tools libpng3-dev

In Redhat Linux the following will install JPG/PNG binaries:

# yum install libpng* libjpeg*  libpng3*

 Now, download the GD-Utils from the following website:


Untar the downloaded Tar file by

# tar -zxvf gd-2.0.33.tar.gz

Change to the directory and run the config script.

# cd gd-2.033

# ./configure

Now, install using

# make && make install

This should install the GD-Utils.

  One Response to “How to install Nagios 2.x in Linux (Debian & Redhat)”

  1. [...] What do you think of this website? http://www.netmonitoring.org/nagios/…debian-redhat/ [...]

 Leave a Reply



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>