環境:vmware workstation虛擬機,server:192.168.118.128 server環境:centos-6.6 nagios-4.1.1 httpd-2.4.20 php-5.6.22 server安裝: 配置apache,文件位置:usr/local/apache2/con ...
環境: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
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文件。