叫我大侠
人可以失败,但不可以被击败
简洁的Nginx Thinkphp配置文件

一般配置为,后面有优化配置:

server {
    listen       80; 
    server_name  wd.cleey.com;
    index index.php index.html index.shtml;
    root  /path/www/web;

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

    location ~ \.php($|/) {
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi.conf;

        #设置PATH_INFO并改写SCRIPT_FILENAME,SCRIPT_NAME服务器环境变量  
        set $path_info "/";
        set $real_script_name $fastcgi_script_name;
        if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
            set $real_script_name $1; 
            set $path_info $2; 
        }   
        fastcgi_param SCRIPT_NAME $real_script_name;
        fastcgi_param PATH_INFO $path_info;
        fastcgi_param           SCRIPT_FILENAME $web_root$fastcgi_script_name;
    }   
}

更好的简洁的配置在这里:

server {
    listen       80; 
    server_name  wd.cleey.com;
    index index.php index.html index.shtml;
    root  /path/www/web;

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

    location ~ \.php($|/) {
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;

        #设置PATH_INFO,注意fastcgi_split_path_info已经自动改写了fastcgi_script_name变量,  
        #后面不需要再改写SCRIPT_FILENAME,SCRIPT_NAME环境变量,所以必须在加载fastcgi.conf之前设置  
        fastcgi_split_path_info  ^(.+\.php)(/.*)$;  
        fastcgi_param  PATH_INFO $fastcgi_path_info;
        include fastcgi.conf;
    }   
}
<< 上一篇 如何在Html中输入框的限制,字数,数字英文等等 Git的使用与命令 下一篇 >>
文章标签
随意 | Created At 2014 By William Clinton | 蜀ICP备14002619号-4 |