How to install Nagios on Ubuntu 20.04

s2 0

Nagios is a popular open source surveillance system.

Nagios takes an inventory of your entire IT infrastructure and ensures that your networks, servers, applications, services and processes are operational. In the event of an error or suboptimal performance, Nagios uses a variety of methods to send notifications.

This article explains how to install Nagios on Ubuntu 20.04.

Install Nagios on Ubuntu 20.04

Nagios 4 is available in the Ubuntu software repository. Installation is pretty straightforward, just run the following commands as a user with sudo privileges:

sudo apt updatesudo apt install nagios4 nagios-plugins-contrib nagios-nrpe-plugin

The above command installs a number of packages including Nagios Core, Nagios Plugins, and Apache.

The Apache configuration file that comes with Nagios depends on the mod_authz_groupfile and mod_auth_digest Modules that are not activated by default. mod_authz_groupfile Module is used to allow or deny access to authenticated by group membership, and mod_authz_groupfile enables MD5 digest authentication.

Run the following commands to enable both modules:

sudo a2enmod authz_groupfile auth_digest

By default, the Apache configuration only allows access to Nagios from localhost and private IPs. We’re changing the configuration so that only authenticated users can view the user interface and issue commands.

Open the configuration file with your text editor:

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

Comment out the lines that begin with Require ip, ““, “” and Require all granted and uncomment the line with Require valid-user, As shown below:


The file also includes instructions for configuring different levels of access.

Once done, restart Apache:

sudo systemctl restart apache2

You can verify that both Apache and Nagios are working properly by checking their status:

sudo systemctl status apache2sudo systemctl status nagios4

create Account

By default, Nagios is configured to grant administrator rights to a user named “nagiosadmin”. With this user you can log into the Nagios web interface and manage your inventory. Use the following htdigest Command to create the user:

sudo htdigest -c /etc/nagios4/htdigest.users Nagios4 nagiosadmin

You will be asked to enter and confirm the user’s password.

New password: 
Re-type new password: 
Adding password for user nagiosadmin

Restart the Apache service for the changes to take effect:

sudo systemctl restart apache2

Configure the firewall

Ubuntu comes with a firewall configuration tool called UFW. With the firewall enabled on your system, make sure you open the HTTP and HTTPS ports:

sudo ufw allow Apache

Access to the Nagios web interface

To access the Nagios web interface, open your preferred browser and enter the domain name or public IP address of your server followed by /nagios:


Enter the nagiosadmin User credentials, and you will be taken to the standard Nagios homepage.


We showed you how to install Nagios on Ubuntu servers.

For more information on configuring and using Nagios, see their documentation

If you run into any problem or have any feedback, please leave a comment below.