ssh里执行:
cat > /usr/local/nginx/conf/pathinfo.conf << 'EOF' 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; EOF
在配置文件中添加一行
include pathinfo.conf;
完整的如下
server { listen 80; server_name www.lnmp.org; index index.html index.htm index.php; root /home/wwwroot/lnmp; location ~ .*\.php { try_files $uri =404; fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; include fcgi.conf; include pathinfo.conf; } 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/wwwlogs/lnmp.log lnmp; }
转载于:https://blog.51cto.com/ww123/1598292