Created
March 7, 2019 07:09
-
-
Save jingmian/21e16a066bce09e6bcd336304ae94b1d to your computer and use it in GitHub Desktop.
docker_dnmp配置thinkphp5的PATH_INFO
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
server_name www.abb8.com; | |
root /var/www/html/abb8/public/; | |
index index.html index.htm index.php; | |
#charset koi8-r; | |
access_log /dev/null; | |
#access_log /var/log/dnmp/nginx.abb8.access.log main; | |
error_log /var/log/dnmp/nginx.abb8.error.log warn; | |
#error_page 404 /404.html; | |
# redirect server error pages to the static page /50x.html | |
# | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
root /usr/share/nginx/html; | |
} | |
# proxy the PHP scripts to Apache listening on 127.0.0.1:80 | |
# | |
#location ~ \.php$ { | |
# proxy_pass http://127.0.0.1; | |
#} | |
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 | |
# | |
location / { | |
if (!-e $request_filename) { | |
rewrite ^(.*)$ /index.php?s=/$1 last; | |
break; | |
} | |
} | |
#1. ~ \.php改为~ \.php(.*),因为要接收.php后面的参数,不能让它被当做目录处理。 | |
#2. 添加fastcgi_split_path_info,该参数后面需指定正则表达式,而且必须要有两个捕获,第一个捕获将会重新赋值给$fastcgi_script_name,第二个捕获将会重新赋值给$fastcgi_path_info。 | |
#3. 添加fastcgi_param PATH_INFO,值为$fastcgi_path_info。 | |
location ~ \.php(.*)$ { | |
fastcgi_pass php72:9000; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_split_path_info ^(.+?\.php)(/.*)$; | |
set $path_info $fastcgi_path_info; | |
fastcgi_param PATH_INFO $path_info; | |
try_files $fastcgi_script_name =404; | |
} | |
# deny access to .htaccess files, if Apache's document root | |
# concurs with nginx's one | |
# | |
#location ~ /\.ht { | |
# deny all; | |
#} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment