默认情况下,Nginx 不支持 pathinfo 配置,通过查看了 Thinkphp Nginx 的配置情况,对虚拟主机配置修改如下:
server {
listen 80;
listen [::]:80;
server_name hhlsw.test;
root /var/www/app/hhlsw/webroot;
index index.php pgms.php hhlsw.php;
location / {
try_files $uri $uri/ =404;
# try_files $uri $uri/ /pgms.php?$query_string;
}
location ~ .php(/|$) {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
# Enable path_info
set $fastcgi_script_name2 $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+.php)(/.+)$") {
set $fastcgi_script_name2 $1;
set $path_info $2;
}
fastcgi_param PATH_INFO $path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name2;
fastcgi_param SCRIPT_NAME $fastcgi_script_name2;
}
}
至此,Brophp 项目在 Nginx 下运行正常!