nagios需要php吗,php教程博客

Nagios安装文档(Apache+Php+Nagios)

需求:监控多台服务器,及时报警

建议:nagios尽量单独安装到一台服务器上,避免与其他服务混合使用服务器

系统整体化境 LANP(Debian6.0.5+Apache+Nagios+Php5.4)

Nagios安装文档(Apache+Php+Nagios)1

一、 安装Linux(Debian)系统3

1. 安装基本的debian环境3

2. 优化debian系统3

二、 安装Apache服务器3

1. 下载apache3

2. 编译安装3

3. 启动apache3

三、 安装PHP4

1. 安装php5.44

2. 优化php4

四、 配置apahce & php4

1. 配置apache的httpd.conf文件4

2. 优化Apache5

3. 重启Apache5

五、 安装Nagios5

1. 安装libgd25

2. 创建nagios用户信息5

3. 下载 nagios5

4. 解压安装nagios6

5. 修改配置文件contacts.cfg6

6. 安装nagios插件6

7. 添加至系统服务7

8. 启动nagios7

六、 配置Apache和Nagios结合点7

1. 创建验证文件7

2. 添加nagios配置文件7

3. 修改apache配置文件8

4. 重启apache9

安装Linux(Debian)系统

安装基本的debian环境

参考文档: http://www.phpno.com/install-and-setup-debian.html

优化debian系统

参考文档:http://www.google.com.hk

安装Apache服务器

下载apache

下载地址:http://httpd.apache.org/download.cgi

编译安装

编译安装参数:

./configure –prefix=/usr/local/apache –enable-so–enable-cgi–enable-info–enable-rewrite–enable-speling–enable-usertrack–enable-deflate –enable-ssl–enable-mime-magic–enable-module=so–enable-module=rewrite–enable-shared=max

启动apache

#/usr/local/apache/bin/apachectl start

#/usr/local/apache/bin/apachectl stop

#/usr/local/apache/bin/apachectl restart

安装PHP

安装php5.4

参考文档:http://www.phpno.com/debian-php5-4.html

注意:和nginx编译参数不同,改为:

./configure –prefix=/usr/local/php –enable-fpm –with-curl –with-gd –enable-mbstring –with-mysql –with-mysqli –enable-gd-native-ttf –enable-sockets –with-jpeg-dir –with-png-dir –with-freetype-dir –with-zlib –enable-ftp –with-apxs2=/usr/local/apache/bin/apxs

优化php

参考文档:http://www.google.com.hk

配置apahce & php

配置apache的httpd.conf文件

A、修改文件/usr/local/apache/conf/httpd.conf添加默认文件

DirectoryIndex index.html index.htm index.php

B、加载支持php的模块

LoadModule php5_module modules/libphp5.so

C、添加php识别

AddType application/x-httpd-php .php

AddType application/x-httpd-php-source .phps

D、测试php

此时创建i.php文件,如何http://ip/i.php可以访问则说明php环境配置ok

优化Apache

参考文档:http://www.google.com.hk

重启Apache

#/usr/local/apache/bin/apachectl restart

安装Nagios

安装libgd2

root@lanp:~# aptitude search libgd2

root@lanp:~# aptitude install libgd2-xpm

创建nagios用户信息

root@dnnp:~# useradd -s /sbin/nologin nagios

root@dnnp:~# mkdir /usr/local/nagios

root@dnnp:~# chown nagios.nagios /usr/local/nagios

下载 nagios

下载nagios相关软件:nagios-3.4.1.tar.gz、nagios-plugins-1.4.16.tar.gz

nagios下载地址:

http://voxel.dl.sourceforge.net/project/nagios/nagios-3.x/nagios-3.4.1/nagios-3.4.1.tar.gz

nagios-plugins下载地址

http://hivelocity.dl.sourceforge.net/project/nagiosplug/nagiosplug/1.4.16/nagios-plugins-1.4.16.tar.gz

解压安装nagios

root@lanp:~/software#tar -zxvf nagios-3.4.1.tar.gz

root@lanp:~/software# cd nagios/

root@lanp:~/software/nagios# ./configure –prefix=/usr/local/nagios

root@lanp:~/software/nagios# make all

root@lanp:~/software/nagios# make install

root@lanp:~/software/nagios# make install-init

root@lanp:~/software/nagios# make install-commandmode

root@lanp:~/software/nagios# make install-config

修改配置文件contacts.cfg

修改配置文件/usr/local/nagios/etc/objects/contacts.cfg,将define contact里面的email改成自己的email

安装nagios插件

Nagios编译参数为:

./configure –prefix=/usr/local/nagios –with-nagios-user=nagios –with-nagios-group=nagios

root@lanp:~/software# tar -zxvf nagios-plugins-1.4.16.tar.gz

root@lanp:~/software# cd nagios-plugins-1.4.16/

root@lanp:~/software/nagios-plugins-1.4.16# ./configure –prefix=/usr/local/nagios –with-nagios-user=nagios –with-nagios-group=nagios

root@lanp:~/software/nagios-plugins-1.4.16# make

root@lanp:~/software/nagios-plugins-1.4.16# make install

添加至系统服务

把Nagios加入到服务列表中以使之在系统启动时自动启动

root@lanp:~# ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios

启动nagios

A、验证nagios配置文件

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

B、启动、关闭nagios

root@lanp:~# /etc/init.d/nagios start/stop/restart

root@lanp:~# service nagios start/stop/restart

配置Apache和Nagios结合点

创建验证文件

文件为/usr/local/nagios/etc/htpasswd.user 用户名为nagiosadmin

root@lanp:~#/usr/local/apache/bin/htpasswd -c /usr/local/nagios/etc/htpasswd.user nagiosadmin

添加nagios配置文件

添加nagios配置文件,文件路径: /usr/local/apache/conf/conf.d/nagios.conf配置文件内容为:

# SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER

# Last Modified: 11-26-2005

#

# This file contains examples of entries that need

# to be incorporated into your Apache web server

# configuration file. Customize the paths, etc. as

# needed to fit your system.

ScriptAlias /nagios/cgi-bin “/usr/local/nagios/sbin”

# SSLRequireSSL

Options ExecCGI

AllowOverride None

Order allow,deny

Allow from all

# Order deny,allow

# Deny from all

# Allow from 127.0.0.1

AuthName “Nagios Access”

AuthType Basic

AuthUserFile /usr/local/nagios/etc/htpasswd.user

Require valid-user

Alias /nagios “/usr/local/nagios/share”

# SSLRequireSSL

Options None

AllowOverride None

Order allow,deny

Allow from all

# Order deny,allow

# Deny from all

# Allow from 127.0.0.1

AuthName “Nagios Access”

AuthType Basic

AuthUserFile /usr/local/nagios/etc/htpasswd.user

Require valid-user

修改apache配置文件

修改apache配置文件/usr/local/apache/conf/httpd.conf

A、在结尾添加Include /usr/local/apache/conf/conf.d/nagios.conf

B、LoadModule cgid_module modules/mod_cgid.so前面的注释去掉

C、AddHandler cgi-script .cgi .pl 前面注释去掉

重启apache

root@lanp:~# /usr/local/apache/bin/apachectl restart

完成验证

打开http://192.168.20.132/nagios/ 输入密码就可以看到nagios 的主页面

主要命令

Nagios文件验证:/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Nagios重启:/etc/init.d/nagios start/stop/restart

Apache重启:/usr/local/apache/bin/apachectl restart

注:nagios必须开启的服务

Php

Apache

Nagios

参考文档:

http://www.phpno.com

http://www.google.com.hk

http://nagios-cn.sourceforge.net/nagios-cn/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值