nginx下无法打开php,报错[error] 5040#0: *1 connect() failed (111: Connection ref ...

本文解决了一个关于 Nginx 报错 connect() failed 的问题,该错误通常出现在配置文件中 fastcgi_pass 指令设置不当的情况下。通过调整 fastcgi_pass 的指向从 TCP socket 到 Unix socket,可以有效解决此问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

以下引自stackouverflow-----------------
报错信息如下:

2013/04/06 17:52:19 [error] 5040#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET /info.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost:8080"


解决办法:

I resolved it, it was a configuration file issue, I added:

location ~ .php$ {

try_files $uri =404; 

 fastcgi_split_path_info ^(.+\.php)(/.+)$; 
 fastcgi_pass unix:/var/run/php5-fpm.sock; 
 fastcgi_index index.php; 
 include fastcgi_params; 
 }
原因:
There are some situations when fastcgi_pass 127.0.0.1:9000; is present in server block and is responsible for this error, in such cases you need change it to fastcgi_pass unix:/var/run/php5-fpm.sock;.  –   Kamil Zieliński   Dec 8 '13 at 10:34

This is because php5-fpm now ships with the Unix socket listen = /var/run/php5-fpm.sockenabled in /etc/php5/fpm/pool.d/www.conf instead of the TCP socket listen = 127.0.0.1:9000. This is typically a little faster. (For google search purposes) ubuntu 14.04 nginx php5-fpm 502 Bad Gateway. I have a feeling a lot of people will be needing this in the near future. There are so many tutorials with the old socket in place.  –   DutGRIFF   May 9 at 6:09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值