connect() php-cgi.sock failed (2: no such file or directory) 问题解决
在LMNP服务器架构中,配置好nginx,php服务后,访问127.0.0.1/index.php主页时,出现以下错误:
2339 connect() to unix:/home/xxx/php/var/php-cgi.sock failed (2: No such file or directory) while connecting to upstream, client: xxxx
出现以上问题请检查nginx和php-fpm的配置:
location ~\.php$ {
root /home/xxxx;
fastcgi_pass unix:/home/xxx/php/var/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;}其中fastcgi_pass为配置nginx与php-fpm的交互路径,一般有两种方式
sock方式:fastcgi_pass unix:/home/xxx/php/var/php-cgi.sock;
立即学习“PHP免费学习笔记(深入)”;
http方式:fastcgi_pass 127.0.0.1;9000;
任选其中一种即可,但必须和php-fpm的配置一致。
<workers> <section> <value name=“listen_address”>127.0.0.1:9000</value> …//省略其他配置 </section> </workers>
其中配置为127.0.0.1:9000与nginx中的配置unix:/home/xxx/php/var/php-cgi.sock不符,所以导致报错。
修改php-fpm配置为:
/home/xxx/php/var/php-cgi.sock
或者修改nginx配置为:
fastcgi_pass 127.0.0.1;9000;
都可以解决以上问题。
以上就是connect() php-cgi.sock failed (2: No such file or directory) 问题解决的内容,更多相关内容请关注PHP中文网(www.php.cn)!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号