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

21 篇文章 1 订阅

配置好lamp后,在浏览器中运行程序后,出现上面的错误。

转自:http://www.xuejiehome.com/blread-1828.html

I'm experiencing 502 gateway errors when accessing a PHP file in a directory (http://domain.com/dev/index.php), the logs simply says this:

2011/09/30 23:47:54 [error] 31160#0: *35 connect() failed (111: Connection refused) while connecting to upstream, client: xx.xx.xx.xx, server: domain.com, request: \"GET /dev/ HTTP/1.1\", upstream: \"fastcgi://127.0.0.1:9000\", host: \"domain.com\"

The answer:

It sounds like you haven't started and configured backend for Nginx. Start php-fpm and add the following to nginx.conf, in http context:

server {
    listen 127.0.0.1;
    server_name localhost;
    error_log /var/log/nginx/localhost.error_log info;
    root /usr/local/nginx/html;
    location ~ \\.php$ {
        root           html;#此处和server下面root保持一致,默认为html
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME   /usr/local/nginx/html/$fastcgi_script_name;
        include        fastcgi_params;
    }
}
 

复制代码

大概意思是你没有启动或者配置php-fpm.其中“/usr/local/nginx/html”为网站根目录。

而我刚好是没有启动php-fpm,在终端运行“service php-fpm start”;

ok,正常运行了。

千里之行,始于足下。改变现在,就是改变未来。改变未来,从现在开始。 个人网站:http://www.wangkongming.cn
企业网站:http://www.hlbaozhuangji.cn/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值