How to Install Nagios on Ubuntu 18.04/16.04 LTS

In this tutorial, We are going to perform How to download and Install Nagios on Ubuntu 18.04/16.04 LTS or any Cloud Instance like Amazon EC2, Azure VM, Google Compute Engine,etc. with preinstalled Ubuntu 18.04/16.04 LTS Step by Step.


Nagios Core is free and open source monitoring tools which is used to monitor the System resources, applications ,Services, Databases and network devices such asRouters,switches,..etc.

Using Nagios Core we can monitor below resources and Network Ports.


  • CPU utilization
  • Memory utilization
  • Disk utilization
  • Logged in users
  • Running processes
  • System Uptime
  • Service states
  • Swap utilization

Network Ports

  • HTTP
  • FTP
  • SSH
  • SMTP
  • Ping
  • Bandwidth Latency
  • Mysql
  • IMAP
  • POP3
  • Tomcat
  • PHP wrapper
  • MySQL


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

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

Ubuntu 16.04 LTS

$ sudo apt-get update
$ sudo apt-get install -y autoconf gcc libc6 make wget unzip apache2 php libapache2-mod-php7.0 libgd2-xpm-dev

Ubuntu 18.04 LTS

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

Step 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

Step 2: Download and Install Nagios on Ubuntu

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

Navigate to /tmp directory

$ cd /tmp

Download and Extract the Nagios Core Setup

$ sudo wget -O nagioscore.tar.gz
$ tar xzf nagioscore.tar.gz
$ cd /tmp/nagioscore-nagios-4.4.5/

Compile the Nagios Core and Install

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

Step 3: 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

Step 4: 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

Step 5: Download and Install Nagios Plugins

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

$ cd /tmp
$ sudo wget --no-check-certificate -O nagios-plugins.tar.gz
$ tar zxf nagios-plugins.tar.gz

Compile and install nagios core plugins,

$ cd /tmp/nagios-plugins-release-2.2.1/
$ sudo ./tools/setup
$ sudo ./configure
$ sudo make
$ sudo make install

Step 6: 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


$ 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

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

Step 7: 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 you will be redirected to nagios default page.

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

nagios core web interface


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:

How to Install Nagios Core on CentOS 7

How to Install Netdata On Ubuntu

How to Install ELK Stack on Ubuntu

How to Install Splunk on Ubuntu 18.04/16.04 LTS

How to Install Splunk Enterprise on CentOS 7


FOSS TechNix

FOSS TechNix (Free,Open Source Software's and Technology Nix*) founded in 2019 is a community platform where you can find How-to Guides, articles for DevOps Tools,Linux and Databases.

Leave a Comment

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

Share via
Copy link
Powered by Social Snap