nginx 报错 connect() failed (111: Connection refused) while connecting to upstream
公司网站搬迁到新服务器后,发现站点访问不了,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的更多相关文章
- Nginx报错 connect() failed (111: Connection refused) while connecting to upstream 的解决方法
今天访问公司的网站突然报错,抛出一些英文,提示看一下Nginx的error.log日志: cd /usr/local/nginx/logs/ 看到了error.log ,下一步 tail -n 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 ...
- 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: * ...
- nginx 解决 connect() failed (111: Connection refused) while connecting to upstream,
嗯哼,刚装了个ubuntu的lnmp,我的天啊,踩的坑比我脂肪还多了 比如刚装完的时候访问显示502, 也不知道什么问题,就去看了一下nginx日志 /var/log/nginx/error.log ...
- 解决connect() failed (111: Connection refused) while connecting to upstream
使用nginx时, 有可能遇到connect() failed (111: Connection refused) while connecting to upstream的问题. 如果upstrea ...
- connect() failed (111: Connection refused) while connecting to upstream
配置好lamp后,在浏览器中运行程序后,出现上面的错误. 转自:http://www.xuejiehome.com/blread-1828.html I'm experiencing 502 gate ...
- connect() failed (111: Connection refused) while connecting to upstream报错处理
新lnmp环境调试项目时,nginx报错如下: 解决: 发现php-fpm.conf是以套接字方式通信,而nginx是以端口方式通信,见下图: 将nginx.conf修改为如下,重新reload即可
- 配置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 ...
- connect() failed (111: Connection refused) while connecting to upstream, cli
php-fpm没有运行 执行如下命令查看是否启动了php-fpm,如果没有则启动你的php-fpm即可 netstat -ant | grep 9000 没有运行为空,有运行显示 tcp 0 0 12 ...
随机推荐
- linux之测试硬盘速度篇
作业三:dd命令测试硬盘速度 [root@localhost 桌面]# dd if=/dev/sdc2 of=/a.txt bs=2M count=2 记录了0+1 的读入 记录了0+1 的写出 10 ...
- SSH报错
1.SSH 加入HQL查询时,报错 antlr.collections.AST.getLine()I 2.百度发现是 因为struts 和 hibernate红都有antlr-2.7.2.jar,但两 ...
- pygame-KidsCanCode系列jumpy-part17-mask-collide碰撞检测
这节我们研究下pygame的几种碰撞检测模式: 如上图,左侧是默认的检测模式:基于矩形的检测(这也是性能最好的模式), 右侧是基于圆形的检测(性能略差于矩形检测). 矩形检测法虽然性能好,但是缺点也很 ...
- What is the NETStandard.Library metapackage?
In my last post, I took a quick look at the Microsoft.AspNetCore meta package. One of the libraries ...
- SOFABolt 源码分析
SOFABolt 是一个轻量级.高性能.易用的远程通信框架,基于netty4.1,由蚂蚁金服开源. 本系列博客会分析 SOFABolt 的使用姿势,设计方案及详细的源码解析.后续还会分析 SOFABo ...
- Javascript Module pattern template. Shows a class with a constructor and public/private methods/properties. Also shows compatibility with CommonJS(eg Node.JS) and AMD (eg requireJS) as well as in a br
/** * Created with JetBrains PhpStorm. * User: scotty * Date: 28/08/2013 * Time: 19:39 */ ;(function ...
- iOS 获取IP
#import <ifaddrs.h> //获取IP #import <arpa/inet.h> //只能获取WIFI下的IP地址 + (NSString *)getIPAdd ...
- Docker中部署Mysql5.7和DbAdmin的docker-compose.yml
一.简述 本文讲Docker通过docker-compose.yml部署Mysql5.7和dbAdmin的方法. 二.文件 1.docker-compose.yml内容如下: version: ' s ...
- html5学习笔记3——高级特性
一:Web存储 数据以 键/值 对存在, web网页的数据只允许该网页访问使用. web存储有两种: localStorage - 没有时间限制的数据存储,存于浏览器缓存 sessionStorage ...
- android mat 转 bitmap
Bitmap bmp = null; Mat tmp = new Mat (height, width, CvType.CV_8U, new Scalar(4)); try { //Imgproc.c ...