关于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的配置端口写错了。

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

posted @ 2019-07-14 23:40  叶随风  阅读(18847)  评论(1编辑  收藏  举报