Nginx 莫名不能用了,直接无法解析 php 文件,打开就空白。不会是配置出错,因为之前一直没问题,可能是最近更新软件升级了 nginx 或是 php-cgi / php-fpm(不确定),然后就不能用了。翻 log 说的是 FastCGI 这个出错,
[error] 7132#0: *3 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: www.com, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.com"[error] 7165#0: *10 upstream sent unsupported FastCGI protocol version: 60 while reading response header from upstream, client: 127.0.0.1, server: www.com, request: “GET / HTTP/1.1”, upstream: “fastcgi://127.0.0.1:80”, host: “www.com”
[error] 7832#0: *83 FastCGI sent in stderr: “Primary script unknown” while reading response header from upstream, client: 127.0.0.1, server: www.com, request: “GET /test.php HTTP/1.1”, upstream: “fastcgi://unix:/var/run/php5-fpm.sock:”, host: “www.com”
改了好几次,确定是 site 配置问题,关键是以前能用现在不能了。真是莫名其妙。
把 nginx 默认的配置
#location ~ \.php$ {
# fastcgi_split_path_info ^(.+\.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
# fastcgi_pass unix:/var/run/php5-fpm.sock;
# fastcgi_index index.php;
# include fastcgi_params;
#}
最下面
include fastcgi_params;
下再加上一行
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
然后就好了。。。话说 nginx 里边都没这个。。
更多 Nginx 配置 见 这里
参考 http://www.verydemo.com/demo_c116_i108420.html