导航:首页 > 编程语言 > nginxphpthinkphp

nginxphpthinkphp

发布时间:2022-11-21 03:00:33

⑴ 如何让nginx支持Thinkphp框架

让nginx支持ThinkPHP框架的做法:

1、打开nginx的配置文件,如果是想某个站点支持,请打开对应站点的配置文件

添加的代码如下:

.........................................

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 fcgi.conf;

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;

}

⑵ 如何让nginx支持ThinkPHP框架

让nginx支持pathinfo,支持thinkphp

我们打开nginx的配置文件,如果是想某个站点支持,请打开对应站点的配置文

我们注释掉配置文件中那些被我圈出来的语句(location ~ \.php$ {……}这一段里面的),我们将对这部分进行重写!

将重写后的代码添加进去。

添加的代码如下:
.........................................
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 fcgi.conf;
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 ~ \.php$ {……}这一段里面的代码

不要漏掉{}
转载

⑶ nginx下怎么支持THinkPHP

thinkphp中设置如下:
“URL_MODEL”=>2
然后访问路径中加“/”的路径都是404状态;
网上很多解决方法,但是都一个样,中国的复制能力太强了,现在发表web集结号解决方法:
主要对未找到的链接在做匹配,
nginx.conf的配置如下方法:
location / {
index index.php;
if (!-e $request_filename) {
rewrite ^/(.*)index.php(.*)$ $1/index.php?s=$2 last; //关键语句
break;
}
}
新加“rewrite ^/(.*)index.php(.*)$ $1/index.php?s=$2 last;” 然后 用thinkphp 通用的兼容的解析方法处理,问题得到解决~
另外可以再解析php的改成如下:
location ~ .php($|/) {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME /usr/data0/wwwroot/$fastcgi_script_name;
include fastcgi_params;
}

⑷ nginx下怎么支持THinkPHP

ThinkPHP支持通过PATHINFO和URL rewrite的方式来提供友好的URL,只需要在配置文件中设置 'URL_MODEL' => 2 即可。在Apache下只需要开启mod_rewrite模块就可以正常访问了,但是Nginx中默认是不支持PATHINFO的,所以nginx默认情况下是不支持thinkphp的。不过我们可以通过修改nginx的配置文件来让其支持thinkphp。
让nginx支持pathinfo,支持thinkphp
1
我们打开nginx的配置文件,如果是想某个站点支持,请打开对应站点的配置文件
如何让nginx支持ThinkPHP框架
2
我们注释掉配置文件中那些被我圈出来的语句(location ~ \.php$ {……}这一段里面的),我们将对这部分进行重写!
如何让nginx支持ThinkPHP框架
3
将重写后的代码添加进去。
如何让nginx支持ThinkPHP框架
4
添加的代码如下:
.........................................
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 fcgi.conf;
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;
}希望能帮到你,我还在后盾人线下面授培训上课学习呢现在没时间,有不会的可以问我,加油吧(。・ω・。)ノ♡

⑸ ThinkPHP在nginx下怎么设置

让nginx支持pathinfo,支持thinkphp

我们打开nginx的配置文件,如果是想某个站点支持,请打开对应站点的配置文件,添加的代码如下:

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

location~.php{
fastcgi_pass127.0.0.1:9000;
fastcgi_indexindex.php;
includefcgi.conf;
set$real_script_name$fastcgi_script_name;
if($fastcgi_script_name~"^(.+?.php)(/.+)$"){
set$real_script_name$1;
set$path_info$2;
}
fastcgi_paramSCRIPT_FILENAME$document_root$real_script_name;
fastcgi_paramSCRIPT_NAME$real_script_name;
fastcgi_paramPATH_INFO$path_info;
}
...................................

⑹ ThinkPHP在nginx下怎么设置

主要对未找到的链接在做匹配,
nginx.conf的配置如下方法:
location / {
index index.php;
if (!-e $request_filename) {
rewrite ^/(.*)index.php(.*)$ $1/index.php?s=$2 last; //关键语句
break;
}
}
新加“rewrite ^/(.*)index.php(.*)$ $1/index.php?s=$2 last;” 然后 用thinkphp 通用的兼容的解析方法处理,问题得到解决~
另外可以再解析php的改成如下:
location ~ .php($|/) {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME /usr/data0/wwwroot/$fastcgi_script_name;
include fastcgi_params;
}如果你对php有兴趣的话,可以向我一样在后盾人平台多看看自己学习学习,时间长了自己就慢慢明白了,希望能帮到你,给个采纳吧谢谢
ヽ(*´з`*)ノ

⑺ ThinkPHP在nginx下怎么设置

问题出在一个网站是基于ThinkPHP框架开发的,用默认的方法配置不行。通用解决方法的配置如下:server{if(!-e$request_filename){rewrite^/(.*)$/index.php/$1last;break;}}location~.+\.php($|/){.set$script$uri;set$path_info"/";if($uri~"^(.+\.php)(/.*)"){set$script$1;set$path_info$2;}fastcgi_paramPATH_INFO$path_info;fastcgi_paramSCRIPT_FILENAME/path/to/web-root$script;}原来fastcgi模块自带了一个指令专门用来解决此类问题的,该指令fastcgi_split_path_info,该指令会根据给定的正则表达式来分隔URL,从而提取出脚本名和pathinfo信息,使用这个指令可以避免使用if语句,配置更简单。(server部分的if语句可以用try_files来代替),新的配置如下:server{try_files$uri/index.php$uri;}location~.+\.php($|/){.fastcgi_split_path_info^(.+\.php)(/.*)$;fastcgi_paramPATH_INFO$fastcgi_path_info;fastcgi_paramSCRIPT_FILENAME/path/to/web-root$fastcgi_script_name;}参考:

⑻ 如何让nginx支持ThinkPHP框架

1、打开nginx的配置文件,如果是想某个站点支持,请打开对应站点的配置文件
2、注释掉配置文件中那些被我圈出来的语句(location ~ \.php$ {……}这一段里面的),将对这部分进行重写!

3、将重写后的代码添加进去。添加的代码如下:
.........................................
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 fcgi.conf;
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;
}

⑼ 如何让nginx支持ThinkPHP框架

Thinkphp开发手册里面是有介绍的,修改nginx.conf

location/{//…..省略部分代码
if(!-e$request_filename){
rewrite^(.*)$/index.php?s=$1last;
break;
}
}

给你一个补全的:

server{
...
location/{
indexindex.htmindex.htmlindex.php;
#访问路径的文件不存在则重写URL转交给ThinkPHP处理
if(!-e$request_filename){
rewrite^/(.*)$/index.php/$1last;
break;
}
}
location~.php/?.*${
root/var/www/html/website;
fastcgi_pass127.0.0.1:9000;
fastcgi_indexindex.php;
#加载Nginx默认"服务器环境变量"配置
includefastcgi.conf;

#设置PATH_INFO并改写SCRIPT_FILENAME,SCRIPT_NAME服务器环境变量
set$fastcgi_script_name2$fastcgi_script_name;
if($fastcgi_script_name~"^(.+.php)(/.+)$"){
set$fastcgi_script_name2$1;
set$path_info$2;
}
fastcgi_paramPATH_INFO$path_info;
fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name2;
fastcgi_paramSCRIPT_NAME$fastcgi_script_name2;
}
}

⑽ 如何让nginx支持ThinkPHP框架

ThinkPHP支持通过PATHINFO和URL rewrite的方式来提供友好的URL,只需要在配置文件中设置 'URL_MODEL' => 2 即可。在Apache下只需要开启mod_rewrite模块就可以正常访问了,但是Nginx中默认是不支持PATHINFO的,所以nginx默认情况下是不支持thinkphp的。不过我们可以通过修改nginx的配置文件来让其支持thinkphp。
END
让nginx支持pathinfo,支持thinkphp

我们打开nginx的配置文件,如果是想某个站点支持,请打开对应站点的配置文件

我们注释掉配置文件中那些被我圈出来的语句(location ~ \.php$ {……}这一段里面的),我们将对这部分进行重写!

将重写后的代码添加进去。

添加的代码如下:
.........................................
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 fcgi.conf;
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 ~ \.php$ {……}这一段里面的代码
不要漏掉{}

阅读全文

与nginxphpthinkphp相关的资料

热点内容
单片机程序员培训 浏览:990
PHP商城源代码csdn 浏览:634
怎么把电脑里文件夹挪出来 浏览:693
java流程处理 浏览:683
ftp创建本地文件夹 浏览:659
腰椎第一节压缩 浏览:738
xp去掉加密属性 浏览:117
2345怎么压缩文件 浏览:982
迷你夺宝新算法 浏览:407
服务器如何防止木马控制 浏览:715
压缩空气用电磁阀 浏览:742
微信为什么不能设置加密认证 浏览:672
邓伦参加密室逃脱视频 浏览:391
音频压缩编码标准 浏览:300
常提到的app是表示什么 浏览:261
天津程序员传销 浏览:349
下班之后的程序员 浏览:73
检测支持ssl加密算法 浏览:344
衢州发布新闻什么APP 浏览:85
中国移动长沙dns服务器地址 浏览:252