How to Install Nagios on Ubuntu 20.04 LTS

In this article we are going to cover How to Install Nagios on Ubuntu 20.04 LTS


  • Ubuntu Server with 20.04 LTS
  • Preinstalled Apache2
  • 1 CPU and 2 GB RAM
  • Firewall Ports 5666,80,443

Before installing Nagios, Install the below per-requisite packages .

sudo apt-get update
sudo apt-get install -y autoconf gcc libc6 make wget unzip apache2 php libapache2-mod-php7.4 libgd-dev

#1: Create Nagios User and Group

Enter below command to create Nagios user and group and add www-data user to nagios group.

sudo useradd nagios
sudo groupadd nagios
sudo make install-groups-users
sudo usermod -a -G nagios www-data

#2: Download Latest Nagios Core Setup on Ubuntu 20.04 LTS

Here We are downloading Nagios Core 4.4.6 setup, To download latest version visit Officical Nagios Site

Navigate to /tmp directory

cd /tmp

Download and Extract the Nagios Core Setup


tar -zxvf nagios-4.4.5.tar.gz

cd /tmp/nagioscore-nagios-4.4.6/

#3: Install Nagios on Ubuntu 20.04 LTS

Compile the Nagios Core and Install Nagios on Ubuntu 20.04 LTS

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

#4: Install and Configure Apache Files

Install and configure apache files using below commands,

sudo make install-webconf
sudo a2enmod rewrite
sudo a2enmod cgi

Restart an Apache to take effect

sudo systemctl restart apache2

#5: Create User Account to Access Nagios Web Interface

We have to create user in apache and set password. Enter below command for same.

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


sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin

#6: Download and Install Nagios Plugins

Navigate to /tmp directory, Download the nagios core plugin and extract it as shown below

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

Compile and install nagios core plugins,

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

#7: Verify Nagios Configuration, Start Nagios and Enable

Verify the Nagios core configuration using below command,

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


Nagios Core 4.4.6
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 2020-04-28
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

Things look okay - No serious problems were detected during the pre-flight check

To start Nagios Service

sudo systemctl start nagios

To enable nagios service at system startup

sudo systemctl enable nagios

#8: Accessing Nagios Web Interface

To access nagios web interface, Open your favorite browser and type your server name or IP followed by nagios/




Once you hit above URL, Enter the credentials of “nagiosadmin” user and password you set above , you will be redirected to nagios default page.

nagios core web interface

To Monitor the services. go to Current status -> Services at left pane as shown below.

nagios service monitor


In this article, we have performed Creating nagios user and group, downloading Nagios Core, compiling and installing nagios, Installing apache configuration files, Downloading and installing Nagios core plugins, verify,start and enable Nagios service, Accessing nagios web interface.

Related Articles:

About DevOps Hint

DevOps Hint Founded in 2020 Community Site where you can find about How to Guides, Articles and Troubleshooting Tips for DevOps, SRE, Sysadmins and Developers.

2 thoughts on “How to Install Nagios on Ubuntu 20.04 LTS”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share via
Copy link