nginx默认配置

来源:互联网 发布:坚持跑步 知乎 编辑:程序博客网 时间:2024/06/16 19:14
server {
    listen 80;
    server_name _;
    access_log /usr/local/nginx/access_nginx.log combined;
    root /var/www/html/default;
    index index.html index.htm index.php;
        location / {
    if (!-e $request_filename) {
        rewrite ^/(.*)$ /index.php/$1;
    }
}
    location /nginx_status {
        stub_status on;
        access_log off;
        allow 127.0.0.1;
        deny all;
        }
        location ~ \.php {
                #fastcgi_pass remote_php_ip:9000;
                fastcgi_pass unix:/dev/shm/php-cgi.sock;
                fastcgi_index index.php;
                include fastcgi_params;
           #nginx配置支持php的pathinfo模式配置方法
       set $real_script_name $fastcgi_script_name;
                        if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
                        set $real_script_name $1;
                        set $path_info $2;
                        }
                fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
                fastcgi_param SCRIPT_NAME $real_script_name;
                fastcgi_param PATH_INFO $path_info;
    }
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
        expires 30d;
        access_log off;
        }
    location ~ .*\.(js|css)?$ {
        expires 7d;
        access_log off;
        }
    }


    include vhost/*.conf;
}
0 0