
Requirements
-
Ubuntu 22.04 Virtono Server : Ensure that you have a fresh installation of Ubuntu 22.04 on a dedicated server or virtual machine. -
Root or Sudo Access : To execute administrative tasks, you’ll need either root access or a user account with sudo privileges. -
Stable Internet Connection : A stable internet connection is essential, as we’ll be downloading packages and updates from the internet.
Update and Upgrade
sudo apt update && apt upgrade -y
Install Prerequisites
sudo apt install autoconf gcc libc6 make wget unzip apache2 apache2-utils php libgd-dev libmcrypt-dev libssl-dev bc gawk dc build-essential snmp libnet-snmp-perl gettext

Create a Nagios User and Group
sudo useradd -m -s /bin/bash nagios sudo groupadd nagcmd sudo usermod -a -G nagcmd nagios sudo usermod -a -G nagcmd www-data
Download and Compile Nagios on Ubuntu
cd /tmp wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.6.tar.gz
Extract and Compile Nagios Core
tar -zxvf nagios-4.4.6.tar.gz cd nagios-4.4.6
./configure --with-nagios-group=nagios --with-command-group=nagcmd make all
Install Nagios Core Binaries and Web Interface Files
sudo make install sudo make install-commandmode sudo make install-init sudo make install-config sudo /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-available/nagios.conf
Install Nagios on Ubuntu Plugins
sudo apt update sudo apt install nagios-plugins cp /usr/lib/nagios/plugins/* /usr/local/nagios/libexec/

sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg sudo systemctl restart nagios sudo systemctl restart apache2
Configure Apache Web Server
sudo ln -s /etc/apache2/sites-available/nagios.conf /etc/apache2/sites-enabled/
sudo a2enmod cgi rewrite
Set Nagios Admin Password
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Start Nagios and Apache Services
sudo systemctl enable nagios
sudo systemctl enable apache2
sudo systemctl restart nagios
sudo systemctl restart apache2
Access Nagios Web Interface

Final Thoughts