Nagios is an open-source monitoring tool that was designed to serve the purpose of monitoring the different networking apps, their sources, and various Linux based devices. With Nagios, we can be vigilant of any critical activities and events of software malfunctions by sending automated alerts to the admins and prevent further damages.

Nagios also keep tabs on networking details(using TCP port, SMTP, POP3, HTTP, NNTP, PING, etc.)

The way it works can be described in the following manner: Nagios sets up security protocols on the different nodes in a network to detect any suspicious activity and notifies the users via an automatic SMS. These problematic activities include HTTP, SSH, FTP fails, other malfunction and critical errors, etc. And displays the web output using current statuses notifications and problem history log file etc. Let’s see how we are going to install Nagios on Ubuntu 20.04 LTS machine.

Some pre-requisites

We’re assuming that you’re at least familiar with the fundamentals of Linux OS, and have a basic know-how of its interactive shell works. Other than that, you should have pre-installed ubuntu 20.04 on your virtual machine or server before proceeding with the installation.

Also, we’re downloading and installing the Nagios package from the official depositories here.

We’ll be using the sudo access mode during the installation. If you’re using your root account, you should exclude ‘sudo’ before each of the commands we’ve used below.

Here’s how to go about installing Nagios on your Virtual machine or server.

Step 1: Check for the updates

First off, we’ll check the web for the latest packages available, download and install them. Use the command below to check for updates.

$ sudo apt update && upgrade

How to install Nagios on Ubuntu 20.04 Monitoring ubuntu

$ sudo apt install -y build-essential apache2 php openssl perl make


php-gd libgd-dev libapache2-mod-php libperl-dev libssl-dev daemon

wget apache2-utils unzip

Step 2: Create a user account

Before we install Nagios, we must create a user account parallel to that of the apache user. Type in the following commands to add a user:

$ sudo useradd nagios


$ sudo groupadd nagcmd


$ sudo usermod -a -G nagcmd nagios


$ sudo usermod -a -G nagcmd www-data

How to install Nagios on Ubuntu 20.04 Monitoring ubuntu

Step 3: Download Nagios from the official website

With the updates and user account took care of, we can download Nagios by visiting the official website.

Alternatively, you can use the following commands to download directly from the web:

How to install Nagios on Ubuntu 20.04 Monitoring ubuntu

$ wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.5.tar.gz

How to install Nagios on Ubuntu 20.04 Monitoring ubuntu

Then extract the files with the help of tar command, and move it to the location of your choice

$ tar -zxvf /tmp/nagios-4.4.5.tar.gz

How to install Nagios on Ubuntu 20.04 Monitoring ubuntu

How to install Nagios on Ubuntu 20.04 Monitoring ubuntu

Step 4: Compile Nagios with Ubuntu 20.04

Type in the following commands:

$ sudo ./configure –with-nagios-group=nagios

–with-command-group=nagcmd –with-httpd_conf=/etc/apache2/sites-enabled/

How to install Nagios on Ubuntu 20.04 Monitoring ubuntu

How to install Nagios on Ubuntu 20.04 Monitoring ubuntu

How to install Nagios on Ubuntu 20.04 Monitoring ubuntu

How to install Nagios on Ubuntu 20.04 Monitoring ubuntu

$ sudo make install-config

How to install Nagios on Ubuntu 20.04 Monitoring ubuntu

$ sudo make install-commandmode

How to install Nagios on Ubuntu 20.04 Monitoring ubuntu

Step 5: Update your email address

Type in the following command:

$ sudo gedit /usr/local/nagios/etc/objects/contacts.cfg

How to install Nagios on Ubuntu 20.04 Monitoring ubuntu

How to install Nagios on Ubuntu 20.04 Monitoring ubuntu

What this command does is that it edits the file (contacts.cfg) located in the directory usr/local/nagios/etc/objects, to include the email address where we want to receive notifications.

Step 6: Fire up the web interface installer

With all of the above input into their places, we can finally move on to the installation of Nagios web interface. Use the following codes, to begin with, the installation.

$ sudo make install-webconf

How to install Nagios on Ubuntu 20.04 Monitoring ubuntu

You’ll need a user account to start using the Nagios web interface, so naturally, you must create a user account first.

Type the following in the interactive shell to create a user account.

$ cd /tmp/nagios-4.4.5$ sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users

How to install Nagios on Ubuntu 20.04 Monitoring ubuntu

How to install Nagios on Ubuntu 20.04 Monitoring ubuntu

Finally, you can restart the Apache Servers.

$ sudo systemctl restart apache2

How to install Nagios on Ubuntu 20.04 Monitoring ubuntu

Step 7: Install Nagios Plugins

If it is not already on /tmp, you can switch directories using:

How to install Nagios on Ubuntu 20.04 Monitoring ubuntu

And then use the following command to start the download.

$ wget https://nagios-plugins.org/download/nagios-plugins-2.3.3.tar.gz

How to install Nagios on Ubuntu 20.04 Monitoring ubuntu

Next, you must extract the file and place it in the resultant directory:

$ tar -zxvf /tmp/nagios-plugins-2.3.3.tar.gz

How to install Nagios on Ubuntu 20.04 Monitoring ubuntu

$ cd /tmp/nagios-plugins-2.3.3/

How to install Nagios on Ubuntu 20.04 Monitoring ubuntu

Once you’ve switched the directories, compile the plugins using the following command:

$ sudo ./configure –with-nagios-user=nagios –with-nagios-group=nagios

How to install Nagios on Ubuntu 20.04 Monitoring ubuntu

How to install Nagios on Ubuntu 20.04 Monitoring ubuntu

How to install Nagios on Ubuntu 20.04 Monitoring ubuntu

Step 8: Using Nagios on Ubuntu

To make sure the configuration was properly seen through, use the following command:

$ sudo /usr/local/nagios/bin/nagios -v

How to install Nagios on Ubuntu 20.04 Monitoring ubuntu

$ cd /usr/local/nagios/etc/nagios.cfg

How to install Nagios on Ubuntu 20.04 Monitoring ubuntu

Turn on the Nagios service to automatically start it every time you boot your VM by using:

$ sudo systemctl enable nagios

How to install Nagios on Ubuntu 20.04 Monitoring ubuntu

Start the services.

$ sudo systemctl start Nagios

How to install Nagios on Ubuntu 20.04 Monitoring ubuntu

Step 9: Get to know the web interface

Go to http://ip-add/nagios/ and have a crack at the web interface. You’ll be asked the user credentials before you log in.

How to install Nagios on Ubuntu 20.04 Monitoring ubuntu

Upon logging in, you should be seeing the member dashboard:

How to install Nagios on Ubuntu 20.04 Monitoring ubuntu

Notice the variety of options on the far left of the interface. Hover over them to find out more.

Wrapping things up

In this tutorial, we’ve seen how to install Nagios on Ubuntu 20.04. We went through and detailed all the steps that need be followed and explained what function each step serves overall. It is much easier to install Nagios from their official repositories than to install it from its source code. But sometimes, it so happens that the repositories fail to deliver the latest versions of Nagios. This, of course, is never the case when you use source code to install Nagios.

About the author

How to install Nagios on Ubuntu 20.04 Monitoring ubuntu

Younis Said

I am a freelancing software project developer, a software engineering graduate and a content writer. I love working with Linux and open-source software.