nginx.conf server节点一般设置

来源:互联网 发布:淘宝手机兼职 编辑:程序博客网 时间:2024/06/07 10:02
    server {
        listen       80;
        #server_name  39.108.108.155;
        server_name www.hutu.cn;
        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   /website/www/hutu;
            index  index.php index.html index.htm;

            if (!-e $request_filename){   #方式1
                rewrite ^/(.*) /index.php last;
            }
        }

        #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;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}
        location ~ \.php$ {
            root /website/www/61wx;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }
        location ~ .*\.(js|css|gif|jpg|jpeg|png|bmp|swf|mp3|mp4|ttf|woff|svg|eot|txt|html|htm)$
        {
            root /website/www/61wx;
            if (-f $request_filename) {
                expires 1d;
                break;
            }
        }
        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }