关于nginx配置的一个报错connect() to unix:/tmp/php-cgi.sock failed (2: No such file or directory)

Posted leafinwind

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了关于nginx配置的一个报错connect() to unix:/tmp/php-cgi.sock failed (2: No such file or directory)相关的知识,希望对你有一定的参考价值。

针对配置php的情况:

linux服务器一般提示这个

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: "GET /index.php HTTP/1.1", upstream: "fastcgi://unix:/tmp/php-cgi.sock:"

win服务器一般提示

connect() failed (111: Connection refused) while connecting to upstream, client: x.x.x.x, server: xxx.xxx.xxx, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000"

这两个提示,一般就是配置文件错误。我们配置nginx支持php时,会有一个

以前,不是配置成:fastcgi_pass   unix:/tmp/php-cgi.sock; (linux机器)

就是配置成:fastcgi_pass   127.0.0.1:9000; (win机器)

结果就报以上错误。此时,这个配置成什么,有系统决定形式,但具体内容,要看php对应的php-fpm的配置文件

/www/server/php/73/etc/php-fpm.conf (我机器的位置)

要看这个文件的内容,编辑该文件,找到 listen = /tmp/php-cgi-73.sock 这一行。将等于号后边的内容复制到nginx的配置文件里,替换fastcgi_pass后边的值。

然后重启nginx即可。

 

而此处我同时还配置了jsp的访问。那么,也报了几乎同样的错误。其实,最终发现,是tomcat的配置端口写错了。

总之,有报错,就一定有配置写错。仔细找找可能错的地方。一般就是路径配置,和参数文件的指定,在一个就是端口。保证这三个地方没问题。一般就不会有太大问题。

以上是关于关于nginx配置的一个报错connect() to unix:/tmp/php-cgi.sock failed (2: No such file or directory)的主要内容,如果未能解决你的问题,请参考以下文章

nginx 报错 connect() failed (111: Connection refused) while connecting to upstream

mysql报错ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)

Nginx基础入门之fastcgi常用配置项说明

MySQL报错的解决Can‘t connect to local MySQL server through socket ‘varlibmysqlmysql.soc

linux系统-Nginx访问报错

关于“svn: Can't connect to host '*.*.*.*': 由于连接方在一段时间后没有正确答复或连接”的解决方法