How to install Nagios on Ubuntu 20.04 LTS

Share on Social Media

Nagios Core is a popular network monitoring tool. In this guide, you will learn how to install Nagios on Ubuntu 20.04 LTS. #centlinux #linux #nagios

What is Nagios Core ?:

Nagios Core, formerly known as Nagios, is a free and open-source computer-software application that monitors systems, networks and infrastructure.

This enterprise network monitoring software offers monitoring and alerting services for servers, switches, applications and services. It alerts users when things go wrong and alerts them a second time when the problem has been resolved.

Nagios was originally designed to run under Linux distros, but it also runs on other Unix variants. It is free software licensed under the terms of the GNU GPL v2 as published by the Free Software Foundation.

It is quiet a long time since Nagios core is in the network monitoring tools market. Therefore, you may found its many forks and alternatives available now a days. Such as Icinga 2, Zabbix, Prometheus, LibreNMS, etc.

Environment Specification:

We are using a minimal Ubuntu 20.04 LTS virtual machine with following specifications.

  • CPU – 3.4 Ghz (2 cores)
  • Memory – 2 GB
  • Storage – 40 GB
  • Operating System – Ubuntu Server 20.04 LTS
  • Hostname –
  • IP Address – /24

Upgrade Ubuntu Software Packages:

Connect with as a superuser by using a ssh client.

Execute apt command to update list of upgradeable software packages on your Ubuntu operating system.

$ sudo apt update
Fetched 4,186 kB in 42s (99.4 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
62 packages can be upgraded. Run 'apt list --upgradable' to see them.

You can now upgrade Ubuntu software packages by executing following apt command.

$ sudo apt -y upgrade
Found linux image: /boot/vmlinuz-5.4.0-66-generic
Found initrd image: /boot/initrd.img-5.4.0-66-generic
Processing triggers for initramfs-tools (0.136ubuntu6.4) ...
update-initramfs: Generating /boot/initrd.img-5.4.0-71-generic

Install Nagios on Ubuntu:

Nagios Core is available in Ubuntu 20.04 LTS via the standard APT repositories. Although the available version is not the most recent, but it is the stable and supported version for your Linux distribution.

Therefore, you can easily install Nagios on Ubuntu by using apt command.

$ sudo apt install -y nagios4 nagios-plugins-contrib nagios-nrpe-plugin
Processing triggers for php7.4-cli (7.4.3-4ubuntu2.4) ...
Processing triggers for libapache2-mod-php7.4 (7.4.3-4ubuntu2.4) ...

During the installation of Nagios core, you may be asked to configure Postfix mail settings.

Postfix Configuration

Select ‘No configuration’ option and click on ‘ok’ to complete setup.

Apache configuration file for Nagios uses following two apache modules. mod_authz_groupfile is used to allow or deny access to authenticated by group membership, and mod_authz_groupfile enables the MD5 digest authentication.

Therefore, you have to enable both of them by executing following command at Linux Bash prompt.

$ sudo a2enmod authz_groupfile auth_digest
[sudo] password for ahmer:
Considering dependency authz_core for authz_groupfile:
Module authz_core already enabled
Enabling module authz_groupfile.
Considering dependency authn_core for auth_digest:
Module authn_core already enabled
Enabling module auth_digest.
To activate the new configuration, you need to run:
  systemctl restart apache2

A default configuration file for Nagios Core is installed in Apache configuration directory. You can modify it according to your requirements.

Use nano text editor to edit Nagios configuration file.

$ sudo nano /etc/apache2/conf-enabled/nagios4-cgi.conf

Locate following lines in this file and comment them by inserting a hash (#) symbol at the start of line.

#Require ip ::1/128 fc00::/7 fe80::/10
#<Files "cmd.cgi">
#Require all    granted

Find and uncomment following line by removing the hash (#) symbol from start of line.

Require valid-user

To access Nagios web interface, you need a user credentials.

You can add a user in authentication file by using following command.

$ sudo htdigest -c /etc/nagios4/htdigest.users Nagios4 nagiosadmin
Adding password for nagiosadmin in realm Nagios4.
New password:
Re-type new password:

Restart Apache service to apply changes that you have made so far.

$ sudo systemctl restart apache2

Allow Apache service in Ubuntu ufw (Uncomplicated Firewall).

$ sudo ufw allow Apache
Rules updated
Rules updated (v6)

Accessing Nagios Web Interface:

Open URL in a web browser.

Nagios Login

Login as nagiosadmin user.

Nagios Welcome Page

After successful login, you have reached at the Nagios default dashboard.

Click on ‘Tactical Overview’ from the left side menu.

Nagios Tactical View

Click on ‘Services’ from the left side menu.

Nagios Default View


You have learned how to install Nagios on Ubuntu 20.04 LTS. To learn more about the Nagios network monitoring software, we recommend that you should buy and read Nagios Core Administration Cookbook – Second Edition (PAID LINK) by Tom Ryder.

Scroll to Top