十年網(wǎng)站開發(fā)經(jīng)驗 + 多家企業(yè)客戶 + 靠譜的建站團隊
量身定制 + 運營維護+專業(yè)推廣+無憂售后,網(wǎng)站問題一站解決
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安裝報錯,所以另外下載了一個pcre包
首先yum remove httpd , 刪除系統(tǒng)自帶的httpd , 關(guān)閉selinux , 關(guān)閉iptables , 啟動項中刪除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 , 這兩個軟件在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會報錯
安裝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 啟動apache服務(wù) , 瀏覽器中輸入localhost可訪問apache測試頁
查看php是否可以使用
把apache下htdocs下的index.html該為index.php
內(nèi)容是
phpinfo();
?>
重啟apache服務(wù),訪問localhost
安裝nagios
安裝前準備
創(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 , 這個文件會告訴apache 哪個路徑下是nagios的文件
也可以在apache配置文件末尾添加一下代碼
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.users 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.users Require valid-user
安裝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源碼包安裝默認用戶是daemon,加入nagcmd組中
usermod -G nagcmd daemon
啟動項添加
chkconfig --add nagios
chkconfig --level 35 nagios on
創(chuàng)建apache目錄驗證文件
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
PS: htpasswd.users是nagios安裝是make install-webconf那一步生成文件中定義好的;nagiosadmin是nagios默認用戶
重啟apache服務(wù)
本地主機訪問localhost/nagios ,會出現(xiàn)輸入用戶名密碼的驗證窗口,登錄之后就可以看到nagios主頁了
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。