nginx配置文件分布式写法

前提是通过编译安装的nginx

首先创建好要使用的目录

mkdir sites-available sites-enabled

在nginx.conf里写http{}里加上一句

include sites-enabled/*;

先在sites-available里写好要用使用的配置文件,每一个配置文件写一个server{}

如:

server {
        listen       80;
        server_name  jpuyy.com;

        #charset koi8-r;
        root /var/www/jpuyy/jpuyy.com;

        location / {

            root /var/www/jpuyy/jpuyy.com;
            index  index.html index.htm index.php;
        }

        log_format jpuyy.com.logs '$remote_addr -$remote_user[$time_local]"$request" '
                                '$status $body_bytes_sent "$http_referer" '
                                '"$http_user_agent" $http_x_forard_for';
        access_log /usr/local/nginx/logs/jpuyy.com.log jpuyy.com.logs;

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        #error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /var/www/jpuyy/jpuyy.com/$fastcgi_script_name;
            include        fastcgi_params;
        }

        location /RPC2 {
          include scgi_params;
          scgi_pass localhost:5000;
        }

}

然后进入sites-enabled

ln -s ../sites-available/jpuyy.com.conf

:)EOT

发表评论

电子邮件地址不会被公开。 必填项已用*标注