Install and Configure Nagios Core
The Nagios server is installed using the command:
Update the system packages.
sudo apt update
Please note that in addition to these two dependency packages, there is still enough to install many additional programs and services.
apt install wget unzip curl openssl build-essential libgd-dev libssl-dev libapache2-mod-php php-gd php apache2 -y
Download Nagios Core Setup files. To download the latest version, visit the [official releases](https://github.com/NagiosEnterprises/nagioscore/releases) site.
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.9.tar.gz
Extract the downloaded files.
tar -zxvf nagios-4.4.9.tar.gz
Navigate to the setup directory.
cd nagios-4.4.9
Run the Nagios Core configure script.
/configure
Compile the main program and CGIs.
make all
Initialize all the installation configuration scripts.
make install-init
Install and configure permissions on the configs' directory.
make install-commandmode
Install sample config files.
make install-config
Install apache files.
make install-webconf
Enable apache rewrite mode.
sudo a2enmod rewrite
Enable CGI config.
a2enmod cgi
Restart the Apache service.
systemctl restart apache2
Create a user and set the password when prompted.
htpasswd -c -b /usr/local/nagios/etc/htpasswd.users nagiosadmin secret
When configuring the Nagios server, you will be prompted to enter a password for
nagiosadmin account for accessing the console.