nginx.conf
新版本的nginx也可以使用fastcgi_split_path_info指令来设置PATH_INFO,旧的方式不再推荐使用,在location段添加如下配置
server {
listen 80;
server_name www.fastadmin.org;
root /var/www/html/AppStoreAdmin/public;
location / {
index index.html index.htm index.php;
#
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php/$1 last;
break;
}
#结束
#autoindex on;
}
location ~ \.php(.*)$ {
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
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使用如下方式配置:
server
{
listen 80;
server_name www.youdomain.com;
index index.html index.htm index.php;
root /home/website;
location / {
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
}
location ~ \.php {
#fastcgi_pass 127.0.0.1:9000;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
# include fcgi.conf;
include fastcgi_params;
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 /status {
stub_status on;
access_log off;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
#access_log /home/access.log access;
}
最后更新于 2020年5月13日