安装思路,仅供参考
####nagios安装
yum install gd-devel -y
useradd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagcmd www
tar xzf nagios-3.5.0.tar.gz
cd nagios
./configure --with-group=nagios --with-user=nagios --with-command-group=nagcmd --prefix=/usr/local/nagios
make all
make install #用于安装主要的程序、CGI及HTML文件
make install-init #用于生成init启动脚本
make install-config #用于安装示例配置文件
make install-commandmode #用于设置相应的目录权限
设置nagios web登陆账号密码
htpasswd -c /usr/local/nagios/etc/nagiospasswd nagiosadmin
New password:
Re-type new password:
[ Adding password for user nagios
给nagios用户开权限,让他能够查看信息! [网站管理员的名字 就是你htpasswd.users中的用户]
vim /usr/local/nagios/etc/cgi.cfg
在所有的nagiosadmin后面添加nagios 多个用户之间用逗号隔开 或者直接替换为nagios即可
]
#####安装插件
tar zxf nagios-plugins-2.0.3.tar.gz
cd nagios-plugins-2.0.3
./configure --with-nagios-user=nagios --with-nagios-group=nagios --prefix=/usr/local/nagios/
make
make install
#########
安装FCGI模块
wget http://www.cpan.org/modules/by-module/FCGI/FCGI-0.67.tar.gz
tar -zxvf FCGI-0.67.tar.gz
cd FCGI-0.67
perl Makefile.PL
make && make install
安装FCGI-ProcManager:
wget http://search.cpan.org/CPAN/authors/id/G/GB/GBJK/FCGI-ProcManager-0.18.tar.gz
tar -xzxf FCGI-ProcManager-0.18.tar.gz
cd FCGI-ProcManager-0.18
perl Makefile.PL
make && make install
安装IO和IO::ALL模块
wget http://search.cpan.org/CPAN/authors/id/G/GB/GBARR/IO-1.25.tar.gz
tar zxvf IO-1.25.tar.gz
cd IO-1.25
perl Makefile.PL
make
make install
cd ..
wget http://search.cpan.org/CPAN/authors/id/I/IN/INGY/IO-All-0.41.tar.gz
tar zxvf IO-All-0.41.tar.gz
cd IO-All-0.41
perl Makefile.PL
make
make install
cd ..
################################################################################################################
nginx的配置
##########安装nginx
yum install gcc openssl-devel pcre-devel zlib-devel -y
useradd -s /sbin/nologin
useradd -s /sbin/nologin www
tar zixf nginx-1.5.1.tar.gz
cd nginx-1.5.1
./configure --prefix=/usr/local/nginx
make && make install
安装php
php-5.4.11.tar.bz2 php-5.2.9-fpm-0.5.10-unofficial.diff.gz
tar fvxj php-5.4.11.tar.bz2
gzip -cd php-5.2.9-fpm-0.5.10-unofficial.diff.gz | patch -d php-5.4.11 -p1
./configure --prefix=/usr/local/php --enable-fastcgi --enable-fpm --disable-fileinfo(当内存小于1G加上这个 不然会报错,若提示不能识别fstcgi,无影响高版本自带此模块不需添加)
make
make install
cp php.ini-production /usr/local/php/lib/php.ini
修改配置文件用户名用户组(与nginx用户、组相同)
PHP-FPM的默认配置文件为/usr/local/php/etc/php-fpm.conf
user www
group www
启动
/usr/local/php/sbin/php-fpm
下载perl脚本,用来产品perl的fast-cgi接口,让nginx以CGI的形式来处理perl ,修改权限为755
wget http://www.mike.org.cn/wp-content/uploads/2011/07/perl-fcgi.zip
解压并复制到nginx目录下(建议)
cp perl-fcgi.pl /usr/local/nginx/
chown 755 /usr/local/nginx/perl-fcgi.pl
chmod +x /usr/local/nginx/perl-fcgi.pl
建立一个cgi启动/停止的脚本,用来管理上面的脚本,用户身份是www,需要根据自己的实际用户来修改 ,修改权限755
vim /usr/local/nginx/conf/start_perl_cgi.sh
######################################
#!/bin/bash
#set -x
#此处需要根据实际情况进行修改
dir=/usr/local/nginx
stop ()
{
#pkill -f $dir/perl-fcgi.pl
kill $(cat $dir/logs/perl-fcgi.pid)
rm $dir/logs/perl-fcgi.pid 2>/dev/null
rm $dir/logs/perl-fcgi.sock 2>/dev/null
echo "stop perl-fcgi done"
}
start ()
{
rm $dir/now_start_perl_fcgi.sh 2>/dev/null
chown www.www $dir/logs
echo "$dir/perl-fcgi.pl -l $dir/logs/perl-fcgi.log -pid $dir/logs/perl-fcgi.pid -S $dir/logs/perl-fcgi.sock" >>$dir/now_start_perl_fcgi.sh
chown www.www $dir/now_start_perl_fcgi.sh
chmod u+x $dir/now_start_perl_fcgi.sh
sudo -u www $dir/now_start_perl_fcgi.sh
echo "start perl-fcgi done"
}
case $1 in
stop)
stop
;;
start)
start
;;
restart)
stop
start
;;
esac
启动perl
/usr/local/nginx/conf/start_perl_cgi.sh start
#########################################
nginx配置文件
vi nginx.conf
user www www;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server
{
listen 80;
index index.html index.htm index.php;
root /usr/local/nagios/share;
auth_basic "Nagios Access";
auth_basic_user_file /usr/local/nagios/etc/nagiospasswd;
location ~ .*\.(php|php5)?$
{
;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~ .*\.(cgi|pl)?$
{
gzip off;
root /usr/local/nagios/sbin;
rewrite ^/nagios/cgi-bin/(.*)\.cgi /$1.cgi break;
fastcgi_pass unix:/usr/local/nginx/logs/perl-fcgi.sock;
fastcgi_param SCRIPT_FILENAME /usr/local/nagios/sbin$fastcgi_script_name;
fastcgi_index index.cgi;
fastcgi_read_timeout 60;
fastcgi_param REMOTE_USER $remote_user;
include fastcgi.conf;
auth_basic "Nagios Access";
auth_basic_user_file /usr/local/nagios/etc/nagiospasswd;
}
location /nagios
{
alias /usr/local/nagios/share;
auth_basic "Nagios Access";
auth_basic_user_file /usr/local/nagios/etc/nagiospasswd;
}
access_log /data1/logs/access_www.log wwwlogs;
}
}
若遇到报错,查看error.log
本文出自 “运维风云二十年” 博客,请务必保留此出处http://huangqingwu.blog.51cto.com/9592044/1674902
原文地址:http://huangqingwu.blog.51cto.com/9592044/1674902