Home » Linux » Debian 12 Bookworm 安装 Nagios Core

第 1 步 - 在 Debian 12 上下载 Nagios 最新版本

sudo apt update
apt install wget curl build-essential unzip openssl libssl-dev apache2 php libapache2-mod-php php-gd libgd-dev
NAGIOS_VER=$(curl -s https://api.github.com/repos/NagiosEnterprises/nagioscore/releases/latest|grep tag_name | cut -d '"' -f 4)
wget https://github.com/NagiosEnterprises/nagioscore/releases/download/$NAGIOS_VER/$NAGIOS_VER.tar.gz
tar xvzf $NAGIOS_VER.tar.gz

第 2 步 - 在 Debian 12 上编译并安装 Nagios Core

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

完成后,您将获得以下输出:

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

现在,您需要创建用户和组。并且 www-data 用户也通过以下命令添加到“nagios”组中:

make install-groups-users 
groupadd -r nagios
useradd -g nagios nagios
sudo usermod -a -G nagios www-data
make all
make install
make install-daemoninit
Output
Init script installed
make install-commandmode
Output
External command directory configured Here you should install the SAMPLE configuration files required as Nagios needs some
configuration files to allow it to start on Debian 12:
make install-config
Output
Config files installed At this point, you need to configure your Apache to serve Nagios web pages. Nagios developers made it
easier to set up Apache. You simply run one command to set up
configuration files and then enable specific Apache modules.
make install-webconf
Output
Nagios/Apache conf file installed
a2enmod rewrite cgi

第 3 步 - 在 Debian 12 上为 Nagios Core 设置 Apache 身份验证

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Output New password: Re-type new password: Adding password for user
nagiosadmin

完成后,使用以下命令为 (/usr/local/nagios/etc/htpasswd.users) 文件设置正确的权限:

chown www-data:www-data /usr/local/nagios/etc/htpasswd.users 
chmod 640 /usr/local/nagios/etc/htpasswd.users

第 4 步 – 在 Debian 12 上安装 Nagios 插件

首先,切换到您的主目录:

cd ~
VER=$(curl -s https://api.github.com/repos/nagios-plugins/nagios-plugins/releases/latest|grep tag_name | cut -d '"' -f 4|sed 's/release-//') 
wget https://github.com/nagios-plugins/nagios-plugins/releases/download/release-$VER/nagios-plugins-$VER.tar.gz 
tar xvf nagios-plugins-$VER.tar.gz
cd nagios-plugins-$VER 
./configure --with-nagios-user=nagios --with-nagios-group=nagios 
make
make install

最后,使用以下命令在 Debian 12 上启动 Nagios 和 Apache 服务:

systemctl restart apache2 
systemctl start nagios.service

步骤6 –通过Web界面访问Nagios核心仪表板

此时,您可以通过在网络浏览器中键入服务器的IP地址,然后输入Nagios来访问Nagios Web界面:

http://<IP Address>/nagios

系统将提示您输入用户名和密码。您可能还记得的用户名是我们在前面的步骤中设置的用户名,即“nagiosadmin”。提供凭据,然后单击登录。

标签: Debian Nagios Nagios Core

添加新评论

V