您好,登錄后才能下訂單哦!
linux下nagios安裝
系統環境: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 , 刪除系統自帶的httpd , 關閉selinux , 關閉iptables , 啟動項中刪除iptables (此用于測試環境 , 生產環境不建議)
安裝 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服務 , 瀏覽器中輸入localhost可訪問apache測試頁
查看php是否可以使用
把apache下htdocs下的index.html該為index.php
內容是
<?php
phpinfo();
?>
重啟apache服務,訪問localhost
安裝nagios
安裝前準備
創建nagcmd用戶組
groupadd nagcmd
創建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目錄下創建nagios腳本
make install-commandmode配置目錄權限
make install-config安裝nagios示例配置文件 , 路徑在/usr/local/nagios/etc
make install-webconf /etc/httpd/conf.d目錄下創建nagios.conf , 這個文件會告訴apache 哪個路徑下是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源碼包安裝默認用戶是daemon,加入nagcmd組中
usermod -G nagcmd daemon
啟動項添加
chkconfig --add nagios
chkconfig --level 35 nagios on
創建apache目錄驗證文件
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
PS: htpasswd.users是nagios安裝是make install-webconf那一步生成文件中定義好的;nagiosadmin是nagios默認用戶
重啟apache服務
本地主機訪問localhost/nagios ,會出現輸入用戶名密碼的驗證窗口,登錄之后就可以看到nagios主頁了
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。