公司网站搬迁到新服务器后,发现站点访问不了,network里面提示502,查看相关的server配置,感觉没有什么问题,经过测试发现txt、html、等非php文件能够直接访问,也就是php访问不了,初步断定有可能是php-fpm没有安装或者没有启动导致。

首先判断php-fpm是否已经安装,没有安装的情况就需要先安装php-fpm,安装可以参数相关资料。

确定好服务器已经安装了php-fpm之后,查看是否已经启动或者直接重启:

[root@izwz9glf2r6p2z8ytslvblz /]# /usr/local/php/sbin/php-fpm start

启动完成后,重启nginx:

[root@izwz9glf2r6p2z8ytslvblz /]# service nginx restart

然后刷新网站页面,但是并没有成功,依然报错。

此时我们先在查看下错误日志 error.log,发现里面都是清一色的报错:

connect() failed (111: Connection refused) while connecting to upstream ......   fastcgi://127.0.0.1:9000 ......

提示的意思就是说连接不上9000端口,这就奇怪了,其实在平时配置nginx的server里面,大部分应该都是配置127.0.0.1:9000 作为分发端口。

现在需要查看一下是否有监听9000端口:

[root@izwz9glf2r6p2z8ytslvblz /]# netstat -ant | grep 9000

发现并没有监听到,但实际上我们的php-fpm已经启动,那现在怎么办呢?

我们去查看一下php-fpm.conf里面的配置:

[root@izwz9glf2r6p2z8ytslvblz /]# vim  /usr/local/php/etc/php-fpm.conf

找到listen:

<value name="listen_address">/tmp/php-cgi.sock</value>

此时我们需要根据配置文件的listen地址做对应的修改:

location ~ \.php$ {
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;

}

改成:

location ~ \.php$ {
        fastcgi_pass   unix:/tmp/php-cgi.sock;
        fastcgi_index  index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

重启nginx。访问成功。

---------------------
作者:ljihe
来源:CSDN
原文:https://blog.csdn.net/ljihe/article/details/78025133
版权声明:本文为博主原创文章,转载请附上博文链接!

nginx 报错 connect() failed (111: Connection refused) while connecting to upstream的更多相关文章

  1. Nginx报错 connect() failed (111: Connection refused) while connecting to upstream 的解决方法

    今天访问公司的网站突然报错,抛出一些英文,提示看一下Nginx的error.log日志: cd  /usr/local/nginx/logs/  看到了error.log ,下一步 tail -n 2 ...

  2. [nginx] connect() failed (111: Connection refused) while connecting to upstream, client: 101.18.123.107, server: localhost,

    nginx一直报错, 2016/12/02 10:23:19 [error] 1472#0: *31 connect() failed (111: Connection refused)while c ...

  3. nginx访问502 gateway,*1 connect() failed (111: Connection refused) while connecting to upstream

    安装好nginx,php环境后,配置虚拟主机,结果访问后就报502 gateway,查看日志文件后,显示错误如下: 2019/04/29 16:24:39 [error] 19433#19433: * ...

  4. nginx 解决 connect() failed (111: Connection refused) while connecting to upstream,

    嗯哼,刚装了个ubuntu的lnmp,我的天啊,踩的坑比我脂肪还多了 比如刚装完的时候访问显示502, 也不知道什么问题,就去看了一下nginx日志  /var/log/nginx/error.log ...

  5. 解决connect() failed (111: Connection refused) while connecting to upstream

    使用nginx时, 有可能遇到connect() failed (111: Connection refused) while connecting to upstream的问题. 如果upstrea ...

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

    配置好lamp后,在浏览器中运行程序后,出现上面的错误. 转自:http://www.xuejiehome.com/blread-1828.html I'm experiencing 502 gate ...

  7. connect() failed (111: Connection refused) while connecting to upstream报错处理

    新lnmp环境调试项目时,nginx报错如下: 解决: 发现php-fpm.conf是以套接字方式通信,而nginx是以端口方式通信,见下图: 将nginx.conf修改为如下,重新reload即可

  8. 配置nginx.config 报错:connect() failed (111: Connection refused) while connecting to upstream解决

    php-fpm没有运行 执行如下命令查看是否启动了php-fpm,如果没有则启动你的php-fpm即可 查看: netstat -ant | grep 9000 执行 /usr/local/php/s ...

  9. connect() failed (111: Connection refused) while connecting to upstream, cli

    php-fpm没有运行 执行如下命令查看是否启动了php-fpm,如果没有则启动你的php-fpm即可 netstat -ant | grep 9000 没有运行为空,有运行显示 tcp 0 0 12 ...

随机推荐

  1. SSD固态硬盘测试工具收集(持续更新)

    https://www.crsky.com/zhuanti/gutaiyingpanceshi.html https://www.crsky.com/zhuanti/ssdjiance.html ht ...

  2. Oracle创建Database Link

    一菜单方式: 打开plsql,点击[File]-[New]-[Database link],打开如下图所示窗口 填好各项信息后,点击[Apply]即可完成Database Link的创建. 二SQL方 ...

  3. 推荐一个好工具:P/Invoke Interop Assistant【转】

    原文地址 :http://write.blog.csdn.net/postedit 在从托管代码里面调用非托管代码的时候,经常会翻阅MSDN找到需要调用的这个程序集里面的关于需要调用方法的签名,还要特 ...

  4. [DevExpress使用随笔]之NavBarControl控件(一)【转】

    https://blog.csdn.net/HXC_HUANG/article/details/78614092 NavBarControl是具有可扩展组的侧导航控件.一.在Winform窗口中拖入N ...

  5. Javascript 生成随机数

    Math.random().toString(16).substring(2) // 固定13位 Math.random().toString(36).substring(2)//倍数不固定 22-2 ...

  6. MySQL中的isnull、ifnull和nullif函数用法

    isnull(expr) 如expr为null,那么isnull()的返回值为1,否则返回值为0. mysql>select isnull(1+1); ->0 mysql>selec ...

  7. shell编程学习笔记(九):Shell中的case条件判断

    除了可以使用if条件判断,还可以使用case 以下蓝色字体部分为Linux命令,红色字体的内容为输出的内容: # cd /opt/scripts # vim script08.sh 开始编写scrip ...

  8. 时间mysql

    查询一天/今天: select * from table where to_days(column_time) = to_days(now()) select * from table where d ...

  9. 单片机成长之路(51基础篇) - 007 CH340CH341最全说明

    比较全的CH340,CH341应用说明 CH340 以前用USB转串口时图方便一般也都是直接买现成的USB转串口模块,但是后面设计需要,不等不将CH340这个模块集成到电路板中,经过多次失败,终于得到 ...

  10. 转-编写CGI小结

    由于Carl要用到我的程序,我们便合作工作.但是他写的程序是Python的,我写的程序是Java的,必须得找一种方式进行通信.尽管有Jython这些东西,但是Carl认为还是CGI最简便.于是,前阵子 ...