配置nginx支持TP框架


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');

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM