您好,登錄后才能下訂單哦!
linux下nagios安裝
系統(tǒng)環(huán)境:CentOS 6.5
安裝包:httpd-2.2.12.tar.bz2 , pcre-8.30.tar.bz2 , php-5.4.6.tar.bz2 , nagios-3.2.3.tar.gz , nagios-plugins-1.4.14.tar.gz
PS: 使用的apache安裝包中的pcre安裝報(bào)錯(cuò),所以另外下載了一個(gè)pcre包
首先yum remove httpd , 刪除系統(tǒng)自帶的httpd , 關(guān)閉selinux , 關(guān)閉iptables , 啟動(dòng)項(xiàng)中刪除iptables (此用于測試環(huán)境 , 生產(chǎn)環(huán)境不建議)
安裝 apache
解壓httpd和pcre tar xf httpd-2.2.12.tar.bz2 -C /usr/src tar xf pcre-8.30.tar.bz2 -C /usr/src
安裝httpd依賴包apr和apr-util , 這兩個(gè)軟件在httpd的srclib文件夾中 , 編譯安裝即可
cd /usr/src/httpd-2.2.12/srclib/apr
./configure --prefix=/usr/local/apr && make && make install && echo "apr installed"
cd /usr/src/httpd-2.2.12/srclib/apr-util
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr && make && make install && echo "apr-util installed"
pcre同樣
cd /usr/src/pcre-8.30
./configure --prefix=/usr/local/pcre && make && make install && echo "pcre installed"
編譯安裝apache
cd /usr/src/httpd-2.2.12
./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-rewrite && make && make install && echo "apache installed"
PS: 如果編譯是加入pcre會(huì)報(bào)錯(cuò)
安裝PHP
解壓PHP包 tar xf php-5.4.6.tar.bz2 -C /usr/src
編譯安裝
cd /usr/src/php-5.4.6
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs && make && make install && echo "php is ok"
cp /usr/src/php-5.4.6/php.ini-development /usr/local/php/php.ini
配置httpd.conf
DirectoryIndex index.html 改為 DirectoryIndex index.php index.html
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz 之后加入 AddType application/x-httpd-php .php
/usr/local/apache2/bin/apachectl start 啟動(dòng)apache服務(wù) , 瀏覽器中輸入localhost可訪問apache測試頁
查看php是否可以使用
把a(bǔ)pache下htdocs下的index.html該為index.php
內(nèi)容是
<?php
phpinfo();
?>
重啟apache服務(wù),訪問localhost
安裝nagios
安裝前準(zhǔn)備
創(chuàng)建nagcmd用戶組
groupadd nagcmd
創(chuàng)建nagios用戶
useradd -G nagcmd -s /sbin/nologin nagios
解壓編譯安裝
tar xf nagios-3.2.3.tar.gz -C /usr/src/
./configure --prefix=/usr/local/nagios && make all && make install
make install-init 在/etc/rc.d/init.d目錄下創(chuàng)建nagios腳本
make install-commandmode配置目錄權(quán)限
make install-config安裝nagios示例配置文件 , 路徑在/usr/local/nagios/etc
make install-webconf /etc/httpd/conf.d目錄下創(chuàng)建nagios.conf , 這個(gè)文件會(huì)告訴apache 哪個(gè)路徑下是nagios的文件
也可以在apache配置文件末尾添加一下代碼
ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin" <Directory "/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.users Require valid-user </Directory> Alias /nagios "/usr/local/nagios/share" <Directory "/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.users Require valid-user </Directory>
安裝nagios插件
tar xf nagios-plugins-1.4.14.tar.gz -C /usr/src
cd /usr/src/nagios-plugins-1.4.14
./configure --prefix=/usr/local/nagios && make && make install
chown -R nagios:nagios /usr/local/nagios
apache源碼包安裝默認(rèn)用戶是daemon,加入nagcmd組中
usermod -G nagcmd daemon
啟動(dòng)項(xiàng)添加
chkconfig --add nagios
chkconfig --level 35 nagios on
創(chuàng)建apache目錄驗(yàn)證文件
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
PS: htpasswd.users是nagios安裝是make install-webconf那一步生成文件中定義好的;nagiosadmin是nagios默認(rèn)用戶
重啟apache服務(wù)
本地主機(jī)訪問localhost/nagios ,會(huì)出現(xiàn)輸入用戶名密碼的驗(yàn)證窗口,登錄之后就可以看到nagios主頁了
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。