ubuntu+nginx+nagios搭建

1,软件环境
Ubuntu 12.04 LTS
nginx/1.1.19
Nagios Core 3.2.3
PHP 5.3.10-1ubuntu3.2 with Suhosin-Patch
PHP 5.3.10-1ubuntu3.2 (fpm-fcgi)


2,安装软件
apt-get install nginx fcgiwrap collectd-core php5-fpm nagios3


3,nginx 配置
root@i-david:~/#vim /etc/nginx/fastcgi_params
fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;
fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;


root@i-david:~/#vim /etc/nginx/conf.d/nagios.conf
server {
        listen 80;
        server_name nagios.i-david.com;

        auth_basic            "Restricted Nagios Area!";
        auth_basic_user_file  /etc/nagios3/htpasswd.users;
        charset utf-8;

        root /usr/share/nagios3/htdocs;
        index index.php;

        location ~ \.php$ {
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                include fastcgi_params;
        }

        location ~ \.cgi$ {
                root /usr/lib/cgi-bin/nagios3;
                rewrite ^/cgi-bin/nagios3/(.*)$ /$1;
                include fastcgi_params;
                fastcgi_param AUTH_USER $remote_user;
                fastcgi_param REMOTE_USER $remote_user;
                fastcgi_param SCRIPT_FILENAME /usr/lib/cgi-bin/nagios3$fastcgi_script_name;
                fastcgi_pass unix:/var/run/fcgiwrap.socket;
        }

        location /stylesheets {
                alias /etc/nagios3/stylesheets;
        }

        location /nagios3/stylesheets {
                alias /etc/nagios3/stylesheets;
        }

        location /nagios3/images {
                 alias /usr/share/nagios3/htdocs/images;
        }
}


4,启动服务
service fcgiwrap start
service php5-fpm start
service nagios3 start
service nginx start


5,验证服务
http://nagios.i-david.com

你可能感兴趣的:(nginx,PHP,ubuntu,cgi,nagios)