Nagios 环境部署
安装服务包
- 操作系统:Linux Centos 6.4 32位
- 安装包:nagios-3.4.3.tar.gz
- 安装包:nagios-plugins-1.4.13.tar.gz
- 安装包:httpd-2.2.23.tar.gz
- 安装包:php-5.4.10.tar.gz
安装依赖包
yum -y install gcc
yum -y install glibc
yum -y install glibc-common
yum -y install gd
yum -y install gd-devel
yum -y install xinetd openssl-devel
yum -y install libxml2-devel*
yum -y install bzip2-devel*
yum -y install curl curl-devel
yum -y install libjpeg-devel
yum -y install openssl-devel*
yum -y install freetype-devel*
yum -y install libpng-devel
yum -y install libmcrypt-devel*
Nagios 安装
1、创建nagios用户和用户组
# 创建nagios用户
useradd -s /sbin/nologin nagios
# 创建nagios安装目录
mkdir /usr/local/nagios
# 赋予所属权限
chown -R nagios.nagios /usr/local/nagios
2、编译安装Nagios
# 解压压缩文件
tar zxvf nagios-3.4.3.tar.gz
# 进入解压文件
cd nagios
# 编译文件
./configure --prefix=/usr/local/nagios
# 编译
make all
# 编译安装
make install
# 编译安装模块init
make install-init
# 编译安装commandmode
make install-commandmode
# 编译安装config
make install-config
3、添加开机自启动
# 添加nagios到服务列表
chkconfig --add nagios
# 设置nagios服务为开机自启动
chkconfig --level 35 nagios on
4、Nagios插件安装
# 解压ngios插件
tar zxvf nagios-plugins-1.4.16.tar.gz
# 进入nagios插件目录
cd nagios-plugins-1.4.16
# 编译文件
./configure --prefix=/usr/local/nagios
# 编译安装
make && make install
5、Apache 安装
# 解压http压缩文件
tar zxvf httpd-2.2.23.tar.gz
# 静茹http文件内
cd httpd-2.2.23
# 编译
./configure --prefix=/usr/local/apache2
# 编译安装
make && make install
6、PHP 安装
# 解压php压缩文件
tar zxvf php-5.4.10.tar.gz
# 进入php文件
cd php-5.4.10
# 编译
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs
# 编译安装
make && make install
Apache 配置
1、修改Apache主配置文件 /usr/local/apache2/conf/httpd.conf,添加参数配置
# 修改1: 修改所属用户、用户组
User nagios
Group nagios
# 修改2:修改添加php索引
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
# 修改3:修改添加调用php模块
AddType application/x-httpd-php .php
2、修改Apche主配置文件 /usr/local/apache2/conf/httpd.conf,添加虚拟主机、用户验证
# 配置文件底行加入如下配置
ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
Alias /nagios "/usr/local/nagios/share"
<Directory "/usr/local/nagios/sbin">
AuthType Basic
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthUserFile /usr/local/nagios/etc/htpasswd
Require valid-user
</Directory>
<Directory "/usr/local/nagios/share">
AuthType Basic
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "nagios Access"
AuthUserFile /usr/local/nagios/etc/htpasswd
Require valid-user
</Directory>
# 添加david验证用户
/usr/local/apache2/bin/htpasswd -c /usr/local/nagios/etc/htpasswd david
3、启动Apache、启动Nagios
# 启动nagios
/etc/init.d/nagios start
# 启动apche
/usr/local/apache2/bin/apachectl start
网站测试:http://192.168.1.1/nagios/
用户验证:用户名、密码