How to install Nagios on Ubuntu 20.04

Nagios is a popular open source system that provides network monitoring functions. It monitors various network apps, their sources, and various Linux-based devices. It supervised Routers, servers, applications, services and ensures that they are operational. In the event of an error, Nagios sends notifications using various methods to prevent further damage. It can also provide the results in visual presentation formats and reports.

Nagios is working on server / agent architecture. Server hosting Nagios (Core) uses plugins to interact with remote hosts, and remote hosts have agents like NRPE installed.

In this guide, we’ll go over how you can do it Install Nagios At Ubuntu 04/20.

Step 1: update the system

As always recommended, make sure that all package lists are updated as follows:

$ sudo apt update

Next, update the system packages to their latest versions:

$ sudo apt upgrade

Step 2: Install the required packages

After upgrading your system, go ahead and install the following prerequisite packages required to install 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’re going to download Nagios Core. Have a look Publications page for the latest version. At the time this manual was written, 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 like this.

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

This creates a directory called. downloaded nagios-4.4.6 in your current working directory.

Download Nagios 4.4.6

Step 4: Install Nagios on Ubuntu

We’re going to install Ubuntu by compiling from source code. So first navigate to the Nagios directory:

$ cd nagios-4.4.6

Next, run the configuration script:

$ ./configure

This will take a few seconds and you will get sample output towards the end, shown below.

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 out as shown above.

So run the following command 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 configuration files in /usr/local/nagios/etc/

$ sudo make install-config

At this point activate the Apache module that is required for the Nagios web interface

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

In addition, you can install the Nagios Peeling 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 into the Nagios interface. We create a user named nagiosadmin with the command:

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

You have to enter a password for the user and confirm it.

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

The password is written in 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, call the command:

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

In your current working directory you have another directory – nagios-plugins-2.3.3

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

$ cd nagios-plugins-2.3.3

Then compile the Nagios plugins from the source code as follows:

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

After the installation is complete, make sure that all configurations are correct as shown.

$ sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Install Nagios on Ubuntu 20.04
confirm that the configurations are OK on Ubuntu 20.04

Step 7: Start and activate the Nagios daemon

When all configurations are set up and ready, proceed as follows and start the Nagios service:

How to start the Nagios service:

$ sudo systemctl enable --now nagios

Confirm that the Nagios service is running.

$ sudo systemctl status nagios

Start and activate the Nagios service
Start and activate the Nagios service

The output confirms that Nagios is operational.

Step 8: access Nagios

And finally we come to the last step where we will access Nagios. To do this, simply open your web browser and go to the URL shown.


You will need to authenticate in the pop-up prompt that appears. Use the credentials provided in step 5 and click the ‘log in‘Button.

Install Nagios on Ubuntu 20.04
Access to Nagios

Once authenticated, you will be directed 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. Thank you for reading and I hope you enjoyed reading this Nagios tutorial.