共计 3879 个字符,预计需要花费 10 分钟才能阅读完成。
环境:VMware Workstation 虚拟机,Server:192.168.118.128
Server 环境:CentOS-6.6 nagios-4.1.1 httpd-2.4.20 php-5.6.22
Server 安装:
useradd nagios 创建用户
mkdir /usr/local/nagios
chown -R nagios:nagios /usr/local/nagios?
tar -xzvf nagios-4.1.1.tar.gz.gz
cd nagios-4.1.1
ll
./configure –prefix=/usr/local/nagios
make all
yum install unzip
make all
make install
make install-init
make install-commandmode
make install-config
chkconfig –add nagios
chkconfig –level 35 nagios on
chkconfig –list nagios
cd ..
rz
ll
tar -xzvf nagios-plugins-2.1.1.tar.gz #插件安装包
tar -xzvf nagios-cn-3.2.3.tar.bz2
ll
rm nagios-cn-3.2.3.tar.bz2
ll
rz
ll
tar -jxvf nagios-cn-3.2.3.tar.bz2 #汉化安装包
cd nagios-cn-3.2.3
ll
./configure
make all
make install
cd ..
ll
mkdir /usr/local/apache2
tar -zxvf httpd-2.4.20.tar.gz
cd httpd-2.4.20
./configure –prefix=/usr/local/apache2
ll
vi README
more INSTALL
./configure –prefix=/usr/local/apache2
find / -name apr
find / -name APR
find / -name apr* #Apr 库支持
yum search apr
yum install apr.x86_64 apr-util.x86_64
yum remove httpd
./configure –prefix=/usr/local/apache2
cd ..
ll
wget http://archive.apache.org/dist/apr/apr-1.4.5.tar.gz
ll
rm apr-1.4.5.tar.gz
rz
ll
tar -zxvf apr-1.5.2.tar.gz
tar -zxvf apr-util-1.5.4.tar.gz
tar -zxvf pcre-8.38.tar.gz
cd apr-1.5.2
./configure –prefix=/usr/local/apr
make && make install
cd ..
cd apr-util-1.5.4
./configure –prefix=/usr/local/apr-util –with-apr=/usr/local/apr/bin/apr-1-config
make && make install
cd ..
cd pcre-8.38
./configure –prefix=/usr/local/pcre
make && make install
cd ..
cd httpd-2.4.20
./configure –prefix=/usr/local/apache2 –enable-so –with-apr=/usr/local/apr –with-apr-util=/usr/local/apr-util/ –with-pcre=/usr/local/pcre
make
make install
cd ..
ll
tar -zxvf php-5.6.22.tar.gz
mkdir /usr/local/php
cd php-5.6.22
./configure –prefix=/usr/local/php –with-apxs2=/usr/local/apache2/bin/apxs
yum install libxml2
find / -name libxml2
find / -name libxml2*
find / -name xml2-config
yum install libxml2-devel
find / -name xml2-config
./configure –prefix=/usr/local/php –with-apxs2=/usr/local/apache2/bin/apxs
make
make test
make install<br> cp php.ini-development /usr/local/lib/php.ini #php 配置
配置 apache,文件位置:usr/local/apache2/conf/http.conf
将进程启动用户改为 nagios,即:
User nagios
Group nagios
LoadModule php5_module modules/libphp5.so # 去掉此行前面注释
找到 DirectoryIndex 增加 index.php
并新增 SetHandler application/x-httpd-php 使其支持解析 php
在最后新增 nagios 配置:
ScriptAlias /nagios/cgi-bin “/usr/local/nagios/sbin”
<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>
Alias /nagios “/usr/local/nagios/share”
<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>
因为指定了访问验证文件,所以需要创建一个:
/usr/local/apache2/bin/htpasswd -c /usr/local/nagios/etc/htpasswd【登录用户名自己设置】回车后输入设置的密码即可
设置完成可以启动 nagios 和 apache 了
出现的问题:
本地可访问,局域网内其他主机不可访问,报 no router,此时是防火墙挡住了,可以关掉 server 防火墙:service iptables stop 或者新增一条放开监听端口 80(http.conf)的规则:iptables -I INPUT -p tcp –dport 80 -j ACCEPT
到此 server 安装完成,当然为了监控其他主机还需要配置相应的 nagios 文件。
————————————– 分割线 ————————————–
在 Ubuntu 下配置 Mrtg 监控 Nginx 和服务器系统资源 http://www.linuxidc.com/Linux/2013-08/88417.htm
使用 snmp+Mrtg 监控 Linux 系统 http://www.linuxidc.com/Linux/2012-11/73561.htm
Mrtg 服务器搭建(监控网络流量)http://www.linuxidc.com/Linux/2012-07/64315.htm
网络监控器 Nagios 全攻略 http://www.linuxidc.com/Linux/2013-07/87067.htm
Nagios 搭建与配置详解 http://www.linuxidc.com/Linux/2013-05/84848.htm
Nginx 环境下构建 Nagios 监控平台 http://www.linuxidc.com/Linux/2011-07/38112.htm
在 RHEL5.3 上配置基本的 Nagios 系统 (使用 Nagios-3.1.2) http://www.linuxidc.com/Linux/2011-07/38129.htm
CentOS 5.5+Nginx+Nagios 监控端和被控端安装配置指南 http://www.linuxidc.com/Linux/2011-09/44018.htm
Ubuntu 13.10 Server 安装 Nagios Core 网络监控运用 http://www.linuxidc.com/Linux/2013-11/93047.htm
————————————– 分割线 ————————————–
Nagios 的详细介绍 :请点这里
Nagios 的下载地址 :请点这里
本文永久更新链接地址 :http://www.linuxidc.com/Linux/2016-06/132187.htm