1.搭建LAMP环境并安装所需要的工具和库
yum -y install httpd php openssl-devel gcc gcc-c++
2.整合Apache和PHP=lamp
[root@c7-41 ~]# cat /etc/httpd/conf/httpd.conf | grep -v "^#"|grep -w "DirectoryIndex"
DirectoryIndex index.php index.html
[root@c7-41 ~]# cat /etc/httpd/conf/httpd.conf | grep -w "AddType application/x-httpd-php .php"
AddType application/x-httpd-php .php
[root@c7-41 ~]# cat /var/www/html/index.php
<?php
phpinfo();
?>
[root@c7-41 ~]# systemctl start httpd
3.安装nagios
3.1创建组和用户
# groupadd nagios
# useradd -g nagios nagios
3.2解压
cd nagios-4.2.1/
./configure --prefix=/usr/local/nagios
make all
make install
make install-init
make install-config
make install-webconf
make install-commandmode
3.3生成Nagios网页认证文件并创建用户
htpasswd -c /usr/local/nagios/etc/htpasswd.users admin
3.4启动nagios和apache
service httpd restart
service nagios restart
3.5安装Nagios-plugins
tar zxf nagios-plugins-2.1.2.tar.gz
cd nagios-plugins-2.1.2/
./configure --prefix=/usr/local/nagios
make
make install
添加一个主机
[root@c7-41 ]# vim /usr/local/nagios/etc/objects/localhost.cfg
define host{
use linux-server ; Name of host templat
e to use
; This host definition
will inherit all variables that are defined
; in (or inherited by)
the linux-server host template definition.
host_name 1708a
alias 1708a
address 127.0.0.1
}