How to install Nagios on Debian 12
- 00:32 lsb_release -a
- 00:43 apt install apache2 libapache2-mod-php php
- 00:54 apt install wget unzip zip autoconf gcc libc6 make apache2-utils libgd-dev
- 01:11 useradd nagios
- 01:17 usermod -a -G nagios www-data
- 01:42 wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.6.tar.gz
- 01:53 tar xzf nagios-4.4.6.tar.gz
- 02:07 cd nagios-4.4.6/
- 02:11 ls -la
- 02:17 ./configure --with-httpd-conf=/etc/apache2/sites-enabled
- 02:41 make all
- 02:53 make install
- 03:07 make install-init
- 03:13 systemctl enable nagios
- 03:29 make install-config
- 03:54 make install-webconfig
- 04:01 htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
- 04:17 a2enmod
- 04:27 systemctl restart apache2
- 04:37 systemctl start nagios
- 04:47 systemctl enable nagios
To Install Nagios On Debian 12
Introduction:
Nagios is an open-source monitoring system for computers. It runs on Linux and can monitor devices that are running Linux, Windows, and UNIX operating systems. The Nagios software checks critical parameters of application, network, and server resources periodically.
Procedure Steps:
Step 1: Check the OS version by using the below command
root@linuxhelp:~# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 12 (bookworm)
Release: 12
Codename: bookworm
Step 2: Install Pre-requirements for Nagios by using the below command
root@linuxhelp:~# apt install apache2 libapache2-mod-php php
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
linux-image-6.1.0-10-amd64
Use 'apt autoremove' to remove it.
The following additional packages will be installed:
apache2-data apache2-utils libapache2-mod-php8.2 php-common php8.2 php8.2-cli
php8.2-common php8.2-opcache php8.2-readline
Suggested packages:
apache2-doc apache2-suexec-pristine | apache2-suexec-custom php-pear
The following NEW packages will be installed:
apache2 apache2-data apache2-utils libapache2-mod-php libapache2-mod-php8.2 php
php-common php8.2 php8.2-cli php8.2-common php8.2-opcache php8.2-readline
0 upgraded, 12 newly installed, 0 to remove and 0 not upgraded.
Need to get 5,056 kB of archives.
After this operation, 23.1 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://deb.debian.org/debian bookworm/main amd64 apache2-data all 2.4.57-2 [160 kB]
Ign:1 http://deb.debian.org/debian bookworm/main amd64 apache2-data all 2.4.57-2
apache2_switch_mpm Switch to prefork
apache2_invoke: Enable module php8.2
Setting up libapache2-mod-php (2:8.2+93) ...
Setting up php8.2 (8.2.7-1~deb12u1) ...
Setting up php (2:8.2+93) ...
Processing triggers for man-db (2.11.2-2) ...
Processing triggers for php8.2-cli (8.2.7-1~deb12u1) ...
Processing triggers for libapache2-mod-php8.2 (8.2.7-1~deb12u1) ...
Step 3: Next step, install the following system dependencies by using the below command
root@linuxhelp:~# apt install wget unzip zip autoconf gcc libc6 make apache2-utils libgd-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
wget is already the newest version (1.21.3-1+b2).
unzip is already the newest version (6.0-28).
unzip set to manually installed.
libc6 is already the newest version (2.36-9+deb12u3).
apache2-utils is already the newest version (2.4.57-2).
apache2-utils set to manually installed.
The following package was automatically installed and is no longer required:
linux-image-6.1.0-10-amd64
Use 'apt autoremove' to remove it.
The following additional packages will be installed:
After this operation, 230 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up libxau-dev:amd64 (1:1.0.9-1) ...
Processing triggers for libc-bin (2.36-9+deb12u3) ...
Setting up libxdmcp-dev:amd64 (1:1.1.2-3) ...
Setting up libxcb1-dev:amd64 (1.15-1) ...
Setting up libx11-dev:amd64 (2:1.8.4-2+deb12u2) ...
Setting up libxpm-dev:amd64 (1:3.5.12-1.1+deb12u1) ...
Setting up libgd-dev:amd64 (2.3.3-9) ...
Step 4: Create Nagios system user and group and add Nagios account to the Apache www-data user, by using following commands.
root@linuxhelp:~# useradd nagios
root@linuxhelp:~# usermod -a -G nagios www-data
Step 5: Go to Nagios webpage and grab the latest version of Nagios Core stable source archive by issuing the following wget command.
root@linuxhelp:~# wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.6.tar.gz
--2023-10-24 02:51:57-- https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.6.tar.gz
Resolving assets.nagios.com (assets.nagios.com)... 45.79.49.120, 2600:3c00::f03c:92ff:fef7:45ce
Connecting to assets.nagios.com (assets.nagios.com)|45.79.49.120|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11333414 (11M) [application/x-gzip]
Saving to: ‘nagios-4.4.6.tar.gz’
nagios-4.4.6.tar.gz 100%[==========================>] 10.81M 3.52MB/s in 3.1s
2023-10-24 02:52:01 (3.52 MB/s) - ‘nagios-4.4.6.tar.gz’ saved [11333414/11333414]
Step 6: Next, extract Nagios by using the below command
root@linuxhelp:~# tar xzf nagios-4.4.6.tar.gz
Step 7: change the Nagios directory and long list the directory by using the below commands
root@linuxhelp:~# cd nagios-4.4.6/
root@linuxhelp:~/nagios-4.4.6# ls -la
total 616
drwxrwxr-x 20 root root 4096 Apr 29 2020 .
drwx------ 6 root root 4096 Oct 24 02:52 ..
-rwxrwxr-x 1 root root 346 Apr 29 2020 aclocal.m4
drwxrwxr-x 2 root root 4096 Apr 29 2020 autoconf-macros
drwxrwxr-x 2 root root 4096 Apr 29 2020 base
drwxrwxr-x 2 root root 4096 Apr 29 2020 cgi
-rw-rw-r-- 1 root root 32590 Apr 29 2020 Changelog
drwxrwxr-x 2 root root 4096 Apr 29 2020 common
Step 8: Now, start to compile Nagios from sources by issuing the below command
root@linuxhelp:~/nagios-4.4.6# ./configure --with-httpd-conf=/etc/apache2/sites-enabled
checking for a BSD-compatible install... /usr/bin/install -c
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
Step 9: In this step, build Nagios files by issuing the below command.
root@linuxhelp:~/nagios-4.4.6# make all
cd ./base && make
make[1]: Entering directory '/root/nagios-4.4.6/base'
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o nagios.o nagios.c
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o broker.o broker.c
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o nebmods.o nebmods.c
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o ../common/shared.o ../common/shared.c
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o query-handler.o query-handler.c
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o workers.o workers.c
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o checks.o checks.c
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o config.o config.c
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o commands.o commands.c
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o events.o events.c
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o flapping.o flapping.c
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o logging.o logging.c
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o macros-base.o ../common/macros.c
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o netutils.o netutils.c
Step 10: Now, install Nagios binary files, CGI scripts and HTML files by issuing the below command.
root@linuxhelp:~/nagios-4.4.6# make install
cd ./base && make install
make[1]: Entering directory '/root/nagios-4.4.6/base'
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/bin
/usr/bin/install -c -s -m 774 -o nagios -g nagios nagios /usr/local/nagios/bin
/usr/bin/install -c -s -m 774 -o nagios -g nagios nagiostats /usr/local/nagios/bin
make[1]: Leaving directory '/root/nagios-4.4.6/base'
cd ./cgi && make install
make[1]: Entering directory '/root/nagios-4.4.6/cgi'
make install-basic
make[2]: Entering directory '/root/nagios-4.4.6/cgi'
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/sbin
for file in *.cgi; do \
/usr/bin/install -c -s -m 775 -o nagios -g nagios $file /usr/local/nagios/sbin;
Step 11: Also, install Nagios configuration file for Apacahe web server, which can be found in /etc/apacahe2/sites-enabled/ directory, by executing the below command.
root@linuxhelp:~/nagios-4.4.6# make install-webconf
/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-enabled/nagios.conf
if [ 0 -eq 1 ]; then \
ln -s /etc/apache2/sites-enabled/nagios.conf /etc/apache2/sites-enabled/nagios.conf; \
fi
*** Nagios/Apache conf file installed ***
Step 12: Next, create nagiosadmin account and a password by using the below command
root@linuxhelp:~/nagios-4.4.6# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin
Step 13: Next restart, start enable the Nagios service by using the below commands.
root@linuxhelp:~/nagios-4.4.6# systemctl restart apache2
root@linuxhelp:~/nagios-4.4.6# systemctl start nagios
root@linuxhelp:~/nagios-4.4.6# systemctl enable nagios
Step 14: Finally go to the browser and enter the IP address as shown in the below image.
http://IP-Address/nagios OR http://DOMAIN/nagios
Step 15: Login the username and password as shown in the below image.
Step 16: This is the dashboard page for Nagios.
Conclusion:
We have reached the end of this article. In this guide, we have walked you through the steps required to install Nagios on Debian 12. Your feedback is much welcome.
Comments ( 0 )
No comments available