TP框架配置中默认URL_MODEL=1,而Nginx默认是不支持PATHINFO的。如果我们只想跑起来tp框架,很简单,只需到更改TP配置,设置URL_MODEL=3(兼容模式)。但是如果要让Nginx支持ThinkPHP PATHINFO需要做如下配置:

1、设置ThinkPHP URL模式URL_MODEL=12、修改nginx配置文件(红色部分更改称相应的内容)
server
{
listen 80;
server_name www.myblog.com;
index index.php;
root /Users/just/git/myblog;

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

3、保存nginx配置并重启

源自: http://yplove.blog.51cto.com/8793750/1749106

如果默认模块可以访问,其他模块不能访问,尝试将入口文件处含有 BIND_MODULE 的注释掉
define('BIND_MODULE','Stage');