純淨ubuntu系統上安裝nagios並使用 一、安裝環境 1.系統 ubuntu-12.04.1-desktop-amd64.iso 2.虛擬機器 VMware® Workstation 8.0.4 build-744019 3.遠程工具 xshell4 二、安裝步驟 1.apt-get install ssh2.建立nagiios使用者和使用者組root@ubuntu:~# useradd -s /sbin/nologin nagiosroot@ubuntu:~# mkdir /usr/local/nagiosroot@ubuntu:~# chown -R nagios.nagios /usr/local/nagios3.開啟sendmail服務4.編譯安裝 nagios cd /usr/local/src #切換到軟體安裝目錄 #上傳所有的安裝檔案 tar -zxvf nagios-3.2.0.tar.gz cd nagios-3.2.0/ ./configure --prefix=/usr/local/nagios make all make install #安裝主程式和CGI、HTML檔案 make install-init #在/etc/rc.d/init.d目錄下建立nagios啟動指令碼 make install-commandmode #配置目錄許可權 make install-config #安裝樣本檔案 #設定開機自啟動 apt-get install chkconfig $sudo ln -s /usr/lib/insserv/insserv /sbin/insserv chkconfig --add nagios chkconfig --level 35 nagios on chkconfig --list nagios 5.安裝nagios外掛程式tar -xzvf nagios-plugins-1.4.14.tar.gz cd nagios-plugins-1.4.14/./configure --prefix=/usr/local/nagiosmake make install6.安裝配置apachetar -xzvf httpd-2.0.63.tar.gz cd httpd-2.0.63/./configure --prefix=/usr/local/apache2makemake install7.安裝phpapt-get install libxml2apt-get install libxml2-dev./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxsapt-get install libxml2-dev ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxsmakemake install8.配置apacheUser nagiosGroup nagios #setting for nagiosScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"<Directory "/usr/local/nagios/sbin">AuthType BasicOptions ExecCGIAllowOverride NoneOrder allow,denyAllow from allAuthName "Nagios Access"AuthUserFile /usr/local/nagios/etc/htpasswdRequire valid-user</Directory> Alias /nagios "/usr/local/nagios/share"<Directory "/usr/local/nagios/share">AuthType BasicOptions NoneAllowOverride NoneOrder allow,denyAllow from allAuthName "Nagios Access"AuthUserFile /usr/local/nagios/etc/htpasswdRequire valid-user</Directory>LoadModule php5_module modules/libphp5.soAddType application/x-httpd-php .php .phtmlAddType applicatoin/x-httpd-php-source .phps 9.產生密碼/usr/local/apache2/bin/htpasswd -c /usr/local/nagios/etc/htpasswd nagios10.啟動apache/usr/local/apache2/bin/apachectl start 有可能有出現的問題 1.php make的時候報錯configure: error: xml2-config not found. Please check your libxml2 installation.apt-get install libxml2apt-get install libxml2-dev2.httpd: Could not determine the server's fully qualified domain name, using 127.0.1.1 for ServerName修改httpd.conf檔案,把其中到#ServerName的注釋去掉即可。 vi /usr/local/apache2/conf/httpd.conf3.You don't have permission to access /nagios/ on this server 這是解析出錯了,需要查看 tail -f /usr/local/apache2/logs/error_log 進行具體的分析,有可能是設定檔 ,也有可能是許可權問題.看到報錯資訊 attempt to invoke directory as script: /usr/local/nagios/share/原來share目錄不能配成ScriptAlias,而只能配成 Alias