用phpstudy配置一个站点的时候,发现一直报错500,后来查看了下error.log.报错如下:
而phpstudy站点配置如下:
server { listen 80; server_name www.cn ; root "F:\\work\\www\\test\_for\_windows"; location / { index index.html index.htm index.php; #autoindex on; } location ~ \\.php(.*)$ { fastcgi_pass 127.0.0.1:9000; 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; } }
后来才发现问题在于:
windows的目录分隔符默认是"\"
而linux默认是"/"
而\t,\r\n,\r恰好是转义字符
而nginx配置文件是可以转义这些字符的,导致配置出错,出现了500问题
至于解决方法,多加一个\就行了,比如\\t,\\r\\n,\\r