nginx和php-fpm配置 错误connect() failed (111: Connection refused) while connecting to upstream connect()

若fpm配置文件中配置如下:

listen = 127.0.0.1:9000

 则对应的nginx.conf中的配置应为:

fastcgi_pass   127.0.0.1:9000;

 此时开启9000端口监听,不会生成sock文件

nginx和php-fpm配置 错误connect() failed (111: Connection refused) while connecting to upstream  connect()

若fpm中的配置为使用Unix套接字,如下:

listen = /run/php/php7.2-fpm.sock

则对应nginx.conf中的配置应为:

fastcgi_pass   unix:/run/php/php7.2-fpm.sock;

此时9000端口未开启,在/run/php/下生成php7.2-fpm.sock文件:

nginx和php-fpm配置 错误connect() failed (111: Connection refused) while connecting to upstream  connect()

若两者不匹配则nginx启动失败。

若fpm为sock,nginx为127.0.0.1:9000,则会出现以下错误:

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

若fpm未127.0.0.1:9000,nginx为sock,则会出现以下错误:

connect() to unix:/run/php/php7.2-fpm.sock failed (2: No such file or directory) while connecting to upstream

 

 

上一篇:Centos7安装php7.2


下一篇:Centos 7 部署lnmp集群架构