首页 > 其他 > 详细

配置nginx支持TP框架

时间:2016-08-17 19:26:38      阅读:203      评论:0      收藏:0      [点我收藏+]
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‘);

 

配置nginx支持TP框架

原文:http://www.cnblogs.com/suxiaolong/p/5781371.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!