導航:首頁 > 編程語言 > 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相關的資料

熱點內容
下班之後的程序員 瀏覽:71
檢測支持ssl加密演算法 瀏覽:341
衢州發布新聞什麼APP 瀏覽:83
中國移動長沙dns伺服器地址 瀏覽:249
wifi密碼加密了怎麼破解嗎 瀏覽:596
linux命令cpu使用率 瀏覽:67
linux實用命令 瀏覽:238
傳奇引擎修改在線時間命令 瀏覽:109
php取域名中間 瀏覽:897
cad命令欄太小 瀏覽:830
php開發環境搭建eclipse 瀏覽:480
qt文件夾名稱大全 瀏覽:212
金山雲伺服器架構 瀏覽:230
安卓系統筆記本怎麼切換系統 瀏覽:618
u盤加密快2個小時還沒有搞完 瀏覽:93
小米有品商家版app叫什麼 瀏覽:94
行命令調用 瀏覽:436
菜鳥裹裹員用什麼app 瀏覽:273
窮查理寶典pdf下載 瀏覽:515
csgo您已被禁用此伺服器怎麼辦 瀏覽:398