第1步:安装apache2

在安装Nagios 服务器软件包之前,请确保已安装Apache2 HTTP服务器。

sudo apt update
sudo apt install apache2
在Ubuntu 16.04/17.10上安装Nagios 服务器

Nagios是一种用于监视网络,硬件,服务器和连接到新工作的其他设备的软件。
是完整的企业级网络,服务器和日志监控系统。

第3步:安装Nagios Server 软件包

安装Nagios和基本插件

sudo apt install nagios3 nagios-plugins-basic

系统会提示我们为Nagiosadmin帐户创建密码。

┌─────────────────────────────────────────────────┤ Configuring nagios3-cgi ├─────────────────────────────────────────────────┐
  │ Please provide the password to be created with the "nagiosadmin" user.                                                      │ 
  │                                                                                                                             │ 
  │ This is the username and password you will use to log in to your nagios installation after configuration is complete.  If   │ 
  │ you do not provide a password, you will have to configure access to nagios yourself.                                        │ 
  │                                                                                                                             │ 
  │ Nagios web administration password:                                                                                         │ 
  │                                                                                                                             │ 
  │ ___________________________________________________________________________________________________________________________ │ 
  │                                                                                                                             │ 
  │                                              <Ok>                                                                           │ 
  │                                                                                                                             │ 
  └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

第4步:配置Nagios 服务器

打开Nagios默认配置文件。

sudo nano /etc/nagios3/nagios.cfg

修改如下:

# EXTERNAL COMMAND OPTION
# This option allows you to specify whether or not Nagios should check
# for external commands (in the command file defined below).  By default
# Nagios will *not* check for external commands, just to be on the
# cautious side.  If you want to be able to use the CGI command interface
# you will have to enable this.
# Values: 0 = disable commands, 1 = enable commands
check_external_commands=1

打开nagios 的apache2配置文件。

sudo nano /etc/nagios3/apache2.conf

设置仅限于localhost和本地子网的访问。

# nagios 1.x:
#Alias /nagios /usr/share/nagios3/htdocs
<DirectoryMatch (/usr/share/nagios3/htdocs|/usr/lib/cgi-bin/nagios3|/etc/nagios3/stylesheets)>
        Options FollowSymLinks
        DirectoryIndex index.php index.html
        AllowOverride AuthConfig

   <IfVersion < 2.3>
       Order Allow,Deny
       Allow From localhost 10.0.0.0/24
   </IfVersion>

修改Nagios文件夹权限。

sudo chgrp -R www-data /var/lib/nagios3 
sudo root@dlp:~# chmod 750 /var/lib/nagios3/rw

重新启动Nagios2和Apache2:

sudo systemctl restart nagios3.service
sudo systemctl restart apache2.service

打开Nagios登录页面:

http://localhost/nagios3

使用上面创建的Nagios管理员和密码登录。

第2步:安装PHP包

Nagios Server还要求安装PHP和相关模块。

下面的命令安装PHP和相关包。

sudo apt install php php-cgi libapache2-mod-php php-common php-pear php-mbstring
日期:2020-07-07 20:57:26 来源:oir作者:oir