日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

nginx訪問php配置,thinkphp5配置nginx访问

發布時間:2024/4/18 php 48 豆豆
生活随笔 收集整理的這篇文章主要介紹了 nginx訪問php配置,thinkphp5配置nginx访问 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

thinkphp采用pathinfo模式;不像laravel和yii配置上去直接就可以干;

測試了兩個不同方式的nginx安裝 yum 和lnmp一鍵安裝包;

一鍵安裝包里面有對pathinfo的支持

下面是配置

一鍵安裝包安裝的lnmp centos7server

{

listen?8080?default_server;

#listen?[::]:80?default_server?ipv6only=on;

server_name?_;

index?index.html?index.htm?index.php;

root??/var/www/html/ibjson;

#error_page???404???/404.html;

#?Deny?access?to?PHP?files?in?specific?directory

#location?~?/(wp-content|uploads|wp-includes|images)/.*\.php$?{?deny?all;?}

include?enable-php.conf;

location?/nginx_status

{

stub_status?on;

access_log???off;

}

location?~?.*\.(gif|jpg|jpeg|png|bmp|swf)$

{

expires??????30d;

}

location?/?{

if?(!-e?$request_filename){

rewrite?^/(.*)$?/index.php?s=/$1?last;

}

}

location?~?.*\.(js|css)?$

{

expires??????12h;

}

location?~?/.well-known?{

allow?all;

}

location?~?/\.

{

deny?all;

}

access_log??/home/wwwlogs/access.log;

}

nginx端口轉發的配置如下server{

listen??????8089;

server_name?_;

root???????????/var/www/html/tp5/public;

index?index.php?index.html?index.htm;

location?~?\.php/?.*?{

fastcgi_pass???127.0.0.1:9000;

fastcgi_index??index.php;

fastcgi_param??SCRIPT_FILENAME??$document_root$fastcgi_script_name;

include????????fastcgi_params;

#定義變量?$path_info?,用于存放pathinfo信息

set?$path_info?"";

#定義變量?$real_script_name,用于存放真實地址

set?$real_script_name?$fastcgi_script_name;

#如果地址與引號內的正則表達式匹配

if?($fastcgi_script_name?~?"^(.+?\.php)(/.+)$")?{

#將文件地址賦值給變量?$real_script_name

set?$real_script_name?$1;

#將文件地址后的參數賦值給變量?$path_info

set?$path_info?$2;

}

#配置fastcgi的一些參數

fastcgi_param?SCRIPT_FILENAME?$document_root$real_script_name;

fastcgi_param?SCRIPT_NAME?$real_script_name;

fastcgi_param?PATH_INFO?$path_info;

}

location?/?{

if?(!-e?$request_filename){

rewrite?^/(.*)$?/index.php/$1?last;

}

#try_files?$uri?$uri/?/index.php?$query_string;

}

}

location?~?\.php(.*)$?{

fastcgi_pass???127.0.0.1:9001;

fastcgi_index??index.php;

fastcgi_split_path_info??^((?U).+\.php)(/?.+)$;

fastcgi_param??SCRIPT_FILENAME??$document_root$fastcgi_script_name;

fastcgi_param??PATH_INFO??$fastcgi_path_info;

fastcgi_param??PATH_TRANSLATED??$document_root$fastcgi_path_info;

include????????fastcgi_params;

}

總結

以上是生活随笔為你收集整理的nginx訪問php配置,thinkphp5配置nginx访问的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。