Install and Configure Nagios Core From Source on Ubuntu 18.04

Last Updated:

In this tutorial we are going to learn how to install and Configure Nagios Core from source on Ubuntu 18.04 for server resource consumption and availability monitoring.

Configure Nagios Core From Source  on Ubuntu 18.04

Run System Update

Update your system package cache;

apt update

Install Required Build Tools and Packages

Installation from the source ensures that we get latest features, security updates, and bug fixes.

Follow through this tutorial to build Nagios and its components from the source.

Install the necessary Nagios build tools and development libraries

apt install -y autoconf gcc libc6 make wget unzip apache2 php \
libapache2-mod-php libgd-dev openssl libssl-dev

Download Nagios Core Source Code

Download the source code of the latest stable release of Nagios Core from here.

wget -P /tmp

Extract Nagios Core Source Code

cd /tmp
tar xzf nagios-4.4.11.tar.gz
cd nagios-4.4.11

Compile and Install Nagios

Compile Nagios;

./configure --with-httpd-conf=/etc/apache2/sites-enabled

Creating sample config files in sample-config/ ...

*** Configuration summary for nagios 4.4.11 2023-04-14 ***:

 General Options:
        Nagios executable:  nagios
        Nagios user/group:  nagios,nagios
       Command user/group:  nagios,nagios
             Event Broker:  yes
        Install ${prefix}:  /usr/local/nagios
    Install ${includedir}:  /usr/local/nagios/include/nagios
                Lock file:  /run/nagios.lock
   Check result directory:  /usr/local/nagios/var/spool/checkresults
           Init directory:  /lib/systemd/system
  Apache conf.d directory:  /etc/apache2/sites-enabled
             Mail program:  /bin/mail
                  Host OS:  linux-gnu
          IOBroker Method:  epoll

 Web Interface Options:
                 HTML URL:  http://localhost/nagios/
                  CGI URL:  http://localhost/nagios/cgi-bin/
 Traceroute (used by WAP):  

Review the options above for accuracy.  If they look okay,
type 'make all' to compile the main program and CGIs.

Compile Nagios program and CGIs

make all

*** Compile finished ***

If the main program and CGIs compiled without any errors, you
can continue with testing or installing Nagios as follows (type
'make' without any arguments for a list of all possible options):

  make test
     - This runs the test suite

  make install
     - This installs the main program, CGIs, and HTML files

  make install-init
     - This installs the init script in /lib/systemd/system

  make install-daemoninit
     - This will initialize the init script
       in /lib/systemd/system

  make install-groups-users
     - This adds the users and groups if they do not exist

  make install-commandmode
     - This installs and configures permissions on the
       directory for holding the external command file

  make install-config
     - This installs *SAMPLE* config files in /usr/local/nagios/etc
       You'll have to modify these sample files before you can
       use Nagios.  Read the HTML documentation for more info
       on doing this.  Pay particular attention to the docs on
       object configuration files, as they determine what/how
       things get monitored!

  make install-webconf
     - This installs the Apache config file for the Nagios
       web interface

  make install-exfoliation
     - This installs the Exfoliation theme for the Nagios
       web interface

  make install-classicui
     - This installs the classic theme for the Nagios
       web interface

*** Support Notes *******************************************

If you have questions about configuring or running Nagios,
please make sure that you:

     - Look at the sample config files
     - Read the documentation on the Nagios Library at:
Nagios Library
before you post a question to one of the mailing lists. Also make sure to include pertinent information that could help others help you. This might include: - What version of Nagios you are using - What version of the plugins you are using - Relevant snippets from your config files - Relevant error messages from the Nagios log file For more information on obtaining support for Nagios, visit:
Nagios Support Home
************************************************************* Enjoy.

Create Nagios User and Group

Create a user and a group that will be used to run Nagios. Add apache user to the nagios group

make install-groups-users
usermod -aG nagios www-data

Install Nagios Core on Ubuntu 18.04

Install Nagios Core binaries, CGIs and HTML files.

make install

Install the init scripts for Nagios services/daemon

make install-daemoninit

Install and configure permissions on the directory for holding the external command file

make install-commandmode

Install sample Nagios configuration files in /usr/local/nagios/etc

make install-config

Install and configure apache web server configuration files and enable apache rewrite and cgi modules

make install-webconf
a2enmod rewrite cgi

If firewall is running, allow apache through it.

ufw allow Apache

Create Nagios Core Basic Web Auth User

Create a user account for logging into the Nagios web interface.

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

where nagiosadmin is the username for logging in to Nagios Web interface and file htpasswd.users stores user credentials.

When adding more users, omit option -c to avoid replacing existing users.

Start Nagios and Apache

Restart and enable both Apache and Nagios services as follows:

systemctl restart apache2;systemctl enable apache2
systemctl restart nagios;systemctl enable nagios

Accessing Nagios Web Interface

Now access the Nagios web interface using the following URL, http://<ip-address-OR-hostname>/nagios.

You will be prompted to login. So login with admin user created above. Once you login, this the Nagios dashboard that welcomes you.

nagios dashboard

Install Nagios Plugins on Ubuntu 18.04

By default, Nagios just monitors itself. However, no plugin has been installed. Thus, download, compile and install Nagios plugins;

wget -P /tmp
cd /tmp
tar xzf nagios-plugins-2.4.4.tar.gz
cd nagios-plugins-2.4.4/
./configure --with-nagios-user=nagios --with-nagios-group=nagios

Compile and install;

make install

The plugins are now installed;

ls /usr/local/nagios/libexec/ | column

check_apt		check_dns		check_ifstatus		check_nagios		check_overcr		check_spop		check_uptime
check_breeze		check_dummy		check_imap		check_nntp		check_ping		check_ssh		check_users
check_by_ssh		check_file_age		check_ircd		check_nntps		check_pop		check_ssl_validity	check_wave
check_clamd		check_flexlm		check_jabber		check_nt		check_procs		check_ssmtp		negate
check_cluster		check_ftp		check_load		check_ntp		check_real		check_swap		remove_perfdata
check_dhcp		check_http		check_log		check_ntp_peer		check_rpc		check_tcp		urlize
check_dig		check_icmp		check_mailq		check_ntp_time		check_sensors		check_time
check_disk		check_ide_smart		check_mrtg		check_nwstat		check_simap		check_udp
check_disk_smb		check_ifoperstatus	check_mrtgtraf		check_oracle		check_smtp		check_ups

Restart Nagios Core service

Now restart Nagios core service to start using the plugins.

systemctl restart nagios

Congratulations! You Nagios server is now ready and running.

nagios localhost monitoring

Other Tutorials

Add Hosts to Nagios Server For Monitoring

Install Nagios NRPE Agent on CentOS 8

Monitor SSL/TLS Certificates Expiry with Nagios

Configure Nagios Email Notification Using Gmail


We're passionate about sharing our knowledge and experiences with you through our blog. If you appreciate our efforts, consider buying us a virtual coffee. Your support keeps us motivated and enables us to continually improve, ensuring that we can provide you with the best content possible. Thank you for being a coffee-fueled champion of our work!

Photo of author
I am the Co-founder of, Linux and the whole FOSS enthusiast, Linux System Admin and a Blue Teamer who loves to share technological tips and hacks with others as a way of sharing knowledge as: "In vain have you acquired knowledge if you have not imparted it to others".

Leave a Comment