How To Install Nagios on Ubuntu 20.04 LTS

Install Nagios on Ubuntu 20.04

In this tutorial, we will show you how to install Nagios on Ubuntu 20.04 LTS. For those of you who didn’t know, Nagios is an open source monitoring tool used to monitor different Linux Machines or different client hosts. It monitors the HTTP, FTP, SSH, SMTP, etc along with the CPU usage, RAM, Disk Usage, and different process that are being run.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you through the step-by-step installation of Nagios on a Ubuntu 20.04 (Focal Fossa) server.


  • A server running one of the following operating systems: Ubuntu 20.04, 18.04, 16.04, and any other Debian-based distribution like Linux Mint.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Nagios on Ubuntu 20.04 LTS Focal Fossa

Step 1. First, make sure that all your system packages are up-to-date by running the following apt commands in the terminal.

sudo apt update
sudo apt upgrade
sudo apt install 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 users and Groups.

Add the user to the Apache webserver group:

sudo useradd nagios
sudo groupadd nagcmd
sudo usermod -a -G nagcmd nagios
sudo usermod -a -G nagcmd www-data

Step 3. Installing Nagios on Ubuntu 20.04.

Now, download the Nagios from the official page or you can get it by the below command through the terminal:

cd /tmp
tar -zxvf /tmp/nagios-4.4.6.tar.gz
cd /tmp/nagios-4.4.6/

Then, Compile the Nagios from the source code:

sudo ./configure --with-nagios-group=nagios --with-command-group=nagcmd --with-httpd_conf=/etc/apache2/sites-enabled/
sudo make all
sudo make install
sudo make install-init
sudo make install-config
sudo make install-commandmode

Step 4. Configure Nagios.

Nagios places configuration files in the /usr/local/nagios/etc directory. Now, with the help of your favorite editor edit the file:

sudo nano /usr/local/nagios/etc/objects/contacts.cfg

Change the email address field to receive the notification:

define contact{
        contact_name                    nagiosadmin             ; Short name of user
        use                             generic-contact         ; Inherit default values from generic-contact template (defined above)
        alias                           Nagios Admin            ; Full name of user

        email                       ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******


Step 5. Installing Nagios Web Interface.

Install the Nagios web interface using the below command:

sudo make install-webconf

Then create a user account as “nagiosadmin” for accessing the Nagios web interface. Make sure to save the password you provided in a safe place or keep in mind as it will be needed later:

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

After it runs the below command:

sudo a2enmod cgi

Next, Restart Apache for the changes to take effect:

sudo systemctl restart apache2

Step 6. Installing Nagios Plugin.

Next steps, Download the latest nagios-plugins source and install using the following commands:

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

Compile and install the plugins:

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

Step 7. Starting Nagios on Ubuntu 20.04.

Double-check the configuration done above by hitting the given command and make sure all configuration pre-checks are okay:

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

Nagios Core 4.4.5
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 2019-08-20
License: GPL

Reading configuration data...
   Read main config file okay...
   Read object config files okay...

Running pre-flight check on configuration data...

Checking objects...
        Checked 8 services.
        Checked 1 hosts.
        Checked 1 host groups.
        Checked 0 service groups.
        Checked 1 contacts.
        Checked 1 contact groups.
        Checked 24 commands.
        Checked 5 time periods.
        Checked 0 host escalations.
        Checked 0 service escalations.
Checking for circular paths...
        Checked 1 hosts
        Checked 0 service dependencies
        Checked 0 host dependencies
        Checked 5 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors:   0

Then, enable Nagios service to start automatically at system startup:

sudo systemctl enable nagios
sudo systemctl start nagios

Step 8. Accessing Nagios.

Nagios will be available on HTTP port 80 by default. Open your favorite browser and navigate to or http://your-server-ip/nagios and complete the required steps to finish the installation. When prompted for username and password you will introduce the username “nagiosadmin” and the password that you entered in step 5.

Install Nagios on Ubuntu 20.04

Congratulations! You have successfully installed Nagios. Thanks for using this tutorial for installing the Nagios monitoring tool in Ubuntu 20.04 LTS (Focal Fossa) systems. For additional help or useful information, we recommend you to check the official Nagios website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!


r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button