Build Nagios 3 from source for Ubuntu 8.04 LTS

Posted by Luke | Nagios, Ubuntu | Sunday 21 June 2009 4:10 am

First install a clean copy of Ubuntu 8.04 LTS and configure it how you see fit (e.g. give it a static IP address to add it to your network).

We’re going to start with installing the NTP time services:

$ sudo apt-get install ntp ntpdate

Now install a fresh Apache web server instance:

$ sudo apt-get install apache2 apache2.2-common apache2-mpm-prefork apache2-utils

Slap on a copy of MySQL:

$ sudo apt-get install mysql-server mysql-client

And a copy of PHP 5 to make our LAMP stack complete:

$ sudo apt-get install php5 php5-common libapache2-mod-php5 php5-mysql

Nagios is going to need GD 2 support. We’re installing it without X pixmap and fontconfig support.

$ sudo apt-get install libgd2-noxpm-dev

We’re going to need to create a user and a group for Nagios to operate under:

$ sudo groupadd -g 9000 nagios
$ sudo groupadd -g 9001 nagcmd
$ sudo useradd -u 9000 -g nagios -a -G nagcmd -d /usr/local/nagios -c "Nagios Admin" nagios
$ sudo usermod -G nagcmd www-data

Create the directories for the Nagios binaries, configuaration and local data storage:

$ sudo mkdir -p /usr/local/nagios /etc/nagios /var/nagios

Set the nagios user we created earlier to be owner of these directories:

$ sudo chown nagios.nagios /usr/local/nagios /etc/nagios /var/nagios

Now you need to download the latest version of Nagios 3 from the Nagios website and extract it somewhere convenient.

Run configure to check if the system is ready to build:

$ ./configure --prefix=/usr/local/nagios --sysconfdir=/etc/nagios --localstatedir=/var/nagios --with-nagios-user=9000 --with-nagios-group=9000 --with-command-group=9001

Compile all binaries:

$ make all

And install:

$ sudo make install

The last thing to do is to run some special installation commands that initialize our Nagios installation and create the initial configuration file etc.:

$ sudo make install-init
$ sudo make install-commandmode
$ sudo make install-config

You should now have a working Nagios version.