How to Install Nagios on Ubuntu 20.04

Nagios is a popular open-source system that provides network monitoring capabilities. It monitors different networking apps, their sources, and various Linux based devices. It monitors routers, servers, applications, services, and ensures that they are up and running. In case of any faults, Nagios sends notification alerts using various methods to prevent further damages. It can also deliver the results in visual representations format and reports.

Nagios works on server/agent architecture. Server hosting Nagios (core) uses plugins to interact with remote hosts and remote hosts have agent such as NRPE installed.

In this guide, we touch base on how you can install Nagios on Ubuntu 20.04.

Step 1: Update the system

As always recommended, ensure that all the package lists are updated as follows:

$ sudo apt update

Next, upgrade the system packages to their latest versions:

$ sudo apt upgrade

Step 2: Install prerequisite packages

After updating your system, proceed and install the following prerequisites packages that are required in the installation of Nagios Core.

$ sudo apt install wget unzip vim curl gcc openssl build-essential libgd-dev libssl-dev libapache2-mod-php php-gd php apache2

Step 3: Download Nagios Core on Ubuntu 20.04

Next, we are going to download Nagios core. Feel free to check the releases page for the latest version. As per the time of writing the guide, the latest version of Nagios is v4.4.6

To download and extract Nagios Core invoke the command:

$ export VER="4.4.6"

Next, use the curl command as follows.

$ curl -SL$VER/nagios-$VER.tar.gz | tar -xzf -

This downloads a directory called nagios-4.4.6 in your present working directory.

Download Nagios 4.4.6

Step 4: Install Nagios on Ubuntu

We are going to install Ubuntu by compiling from source. So, first, navigate into the Nagios directory:

$ cd nagios-4.4.6

Next, run the configure script:

$ ./configure

This will take a few seconds and be sure to get a sample output shown below towards the end.

install Nagios on Ubuntu 20.04
install Nagios on Ubuntu 20.04

To compile the main program alongside the CGIs, run the make all command as follows.

$ sudo make all

Next, create the group users as follows.

$ sudo make install-groups-users
$ sudo usermod -a -G nagios www-data
create group users
create group users

Then, install Nagios Core 4.x on your Ubuntu 20.04 system

$ sudo make install

Towards the end, some additional instructions will be printed as shown above.

Therefore run the command below to install the init script in /lib/systemd/system path.

$ sudo make install-init

Next, Install and configure permissions on the directory that contains the external command file.

$ sudo make install-commandmode

Then install sample config files in /usr/local/nagios/etc/

$ sudo make install-config

At this point, enable the Apache module required for Nagios web interface

$ sudo make install-webconf
$ sudo a2enmod rewrite cgi
$ sudo systemctl restart apache2

Additionally, feel free to install the Nagios exfoliation theme as follows:

$ sudo make install-exfoliation

For the classic Nagios theme, run the following command.

$ sudo make install-classicui

Step 5: Create a Nagios login web user

You need to create a login user that you will use to log in to Nagios interface. We will create a user called nagiosadmin using the command:

$ sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

You will be required to provide a password for the user and confirm it.

Create Nagios web login user.
Create Nagios web login user.

The password is written to the /usr/local/nagios/etc/htpasswd.users file.

Step 6: Install Nagios Plugins

Nagios are used to extend the functionality of Nagios. You can get a glimpse of the latest plugins from GitHub.

To download the plugins, invoke the command:

$ VER="2.3.3"
$ curl -SL$VER/nagios-plugins-$VER.tar.gz | tar -xzf -

On your current working directory, you will have another directory - nagios-plugins-2.3.3

To install the plugins, navigate to the plugins source directory:

$ cd nagios-plugins-2.3.3

Then compile the Nagios plugins from source as follows:

$ ./configure --with-nagios-user=nagios --with-nagios-group=nagios
$ sudo make install

Once the installation is complete verify that all the configurations are in order as shown.

$ sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
install Nagios on Ubuntu 20.04
confirm configurations are ok on Ubuntu 20.04

Step 7: Start and enable Nagios daemon

With all the configurations set and ready, proceed and start the nagios service as follows:

To start the Nagios service run:

$ sudo systemctl enable --now nagios

Confirm that Nagios service is running.

$ sudo systemctl status nagios
Start and enable Nagios service
Start and enable Nagios service

The output confirms that Nagios is up and running.

Step 8: Access Nagios

And finally, we get to the last step where we shall access Nagios. To do so, simply open your web browser and head to the URL shown.


You will be required to authenticate in the pop-up prompt shown. Use the credentials you provided in Step 5 and click on the 'Sign In' button.

install Nagios on Ubuntu 20.04
Access Nagios

Once authenticated, you will be ushered to the dashboard shown below.

install Nagios on Ubuntu 20.04
install Nagios on Ubuntu 20.04


In this tutorial we learned how to install Nagios on Ubuntu 20.04 LTS. Thanks for reading and I hope you have enjoyed reading this Nagios tutorial.

1 thought on “How to Install Nagios on Ubuntu 20.04”... add one

Leave a Comment