LNMP环境开启pathinfo模式支持特定的网站环境

刚巧早上在准备写点什么的时候有网友咨询如何在LNMP环境下开启pathinfo模式支持一些网站的环境需要。因为默认情况下LNMP一键安装包中是没有启动pathinfo的,我们需要手工设置CONF文件才可以启动。具体的内容如下:

第一步、我们需要找到当前网站所在的conf文件(/usr/local/nginx/conf/vhost/对应的域名文件)

location ~ .*\\.(php|php5)$ { try_files $uri =404; fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; include fcgi.conf; }

找到上面的文件

第二步、替换成下面的内容

if (!-e $request_filename) { rewrite ^\\/([^\\.]*)$ /index.php/$1 last; break; } location ~ \\.php { try_files $uri =404; fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; include fcgi.conf; set $path_info \”\”; 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; }

这样2步就可以解决LNMP环境开启pathinfo模式支持特定的网站环境。

推荐站内搜索:ip地址查询器、域名空间购买、韩国独立服务器、外网ip查询、免费mysql空间、云服务器官网、域名查下、国外空间租用、美国免费主机、中文国际域名、