Installing Nagios Core on Ubuntu Server 24.04

Purpose:

The purpose of this guide is to setup a Nagios Core installation on Ubuntu Server 24.04. You can visit the Nagios website for more information:

Nagios Core – Installing Nagios Core From Source

Assumptions:

  • Working hypervisor with Ubuntu 24.04 installed
  • Some basic Linux Knowledge

Guide:

Downloading and Installing Nagios

Prerequisites:

sudo apt-get update
sudo apt-get install -y autoconf gcc libc6 make wget unzip apache2 php libapache2-mod-php libgd-dev ufw
sudo apt-get install -y openssl libssl-dev

Downloading Nagios:

cd /tmp
wget -O nagioscore.tar.gz $(wget -q -O - <https://api.github.com/repos/NagiosEnterprises/nagioscore/releases/latest>  | grep '"browser_download_url":' | grep -o 'https://[^"]*')
tar xzf nagioscore.tar.gz

Compile:

cd /tmp/nagios-*
sudo ./configure --with-httpd-conf=/etc/apache2/sites-enabled
sudo make all

User and Group Creation:

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

Install Binaries:

sudo make install

Install Service/Daemon

sudo make install-daemoninit

Install Command Mode

sudo make install-commandmode

Install Configuration Files

sudo make install-config

Install Apache Config Files

sudo make install-webconf
sudo a2enmod rewrite
sudo a2enmod cgi

Configure Firewall

sudo ufw allow Apache
sudo ufw reload

Create a Nagiosadmin User Account

Note: You will be prompted to enter a password for this user

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

Restart Apache Web Server

sudo systemctl restart apache2.service

Start Service/Daemon

sudo systemctl start nagios.service

Testing Nagios

Navigate to http://IPAddressOfServer/nagios and this will bring you to a log in page.

After using the credentials we set up just a few moments ago, please enter those and log in.

It should bring you to the following page:

Installing Plugins

Nagios relies on plugins to function. Lets install these next!

Make sure the following packages are installed:

sudo apt-get install -y autoconf gcc libc6 libmcrypt-dev make libssl-dev wget bc gawk dc build-essential snmp libnet-snmp-perl gettext

Downloading, Compile, and Install

cd /tmp
wget -O nagios-plugins.tar.gz $(wget -q -O - <https://api.github.com/repos/nagios-plugins/nagios-plugins/releases/latest>  | grep '"browser_download_url":' | grep -o 'https://[^"]*')
tar zxf nagios-plugins.tar.gz
cd /tmp/nagios-plugins-*/
sudo ./configure
sudo make
sudo make install

Conclusion:

You should be able to see a working Nagios Core dashboard when you visit the address listed above.

Alex Wilfong
Alex Wilfong
Articles: 4