关于 Nginx 的 fastcgi_pass 配置错误
条评论项目在 Nginx 下配置完成后访问报了 502 错误,查看 nginx 日志,发现错误信息为:
connect() to unix:/tmp/php-cgi.sock failed (2: No such file or directory) while connecting to upstream, client: x.x.x.x, server: xxx.xxx.xxx, request: "POST /index.php HTTP/1.1", upstream: "fastcgi://unix:/tmp/php-cgi.sock:"
发现是 nginx 配置文件中的 fastcgi_pass 和 php-fpm 的 listen 不一致的问题
找到服务器的 php-fpm 的的配置文件 /usr/local/php/etc/php-fpm.conf
查看 php-fpm.conf 中的 listen 为:listen = 127.0.0.1:9000
修改 nginx 下的 vhost 配置文件为 fastcgi_pass 127.0.0.1:9000;
然后重启 nginx 即可。