LNMP 配置NGINX 支持thinkphp5的PATHINFO模式

1,修改PHP.INI 支持 PHPINOF

PHP配置文件:/usr/local/php/etc/php.ini

更改php.ini
找到:cgi.fix_pathinfo=0
更改为:cgi.fix_pathinfo=1

2.修改nginx对应配置文件

/usr/local/nginx/conf/vhost/你的域名配置文件

server {
listen 80;
server_name www.dreamus.net;
root /your project/public;
index index.php index.html index.htm;

#error_page 404 /404.html;
location ~* ^.+.(jpg|jpeg|gif|css|png|js|thumb) {
expires 30d;
}
location / {
try_files $uri @default;
}

location @default {
#fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param PATH_TRANSLATED $document_root/index.php;
include fastcgi_params;
}

location ~ \.php($|/) {
# fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_split_path_info ^(.+?\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
include fastcgi_params;
}

}

3.重启lnmp即可。

service nginx restart

打开对应的网站输入路由即可   https://your domain/api/v1/banner/1a

You May Also Like

About the Author: 烟淡黄昏