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 ...
随机推荐
- vue中引用vux
官网看不懂,网上搜了下,以备不时之需 这是官网说明文档,看不懂的啊. Vux使用教程: 1,在项目里安装vux cnpm install vux --save 2,在项目里安装vux-loader(这 ...
- 11 week blog
Obtaining the JSON: 1.首先,我们将把要检索的JSON的URL存储在变量中. 2.要创建请求,我们需要使用new关键字从XMLHttpRequest构造函数创建一个新的请求对象实例 ...
- JavaScript数组(三)数组对象使用整理
一.数组声明方法1. var a=new Array();2. var a=new Array([size]);3.var a=new Array(['a'],[1],['b'],[123]);4. ...
- [Functional Programming] Functional JS - Pointfree Logic Functions
Learning notes. Video. Less than: If you use 'ramda', you maybe know 'lt, gt'.. R.lt(2, 1); //=> ...
- htop使用详解
一.Htop的使用简介 大家可能对top监控软件比较熟悉,今天我为大家介绍另外一个监控软件Htop,姑且称之为top的增强版,相比top其有着很多自身的优势.如下: 两者相比起来,top比较繁琐 默认 ...
- golang 使用pprof和go-torch做性能分析
软件开发过程中,项目上线并不是终点.上线后,还要对程序的取样分析运行情况,并重构现有的功能,让程序执行更高效更稳写. golang的工具包内自带pprof功能,使找出程序中占内存和CPU较多的部分功能 ...
- Nginx——location常见配置指令,alias、root、proxy_pass
1.[alias] 别名配置,用于访问文件系统,在匹配到location配置的URL路径后,指向[alias]配置的路径.如: location /test/ { alias /home/sftp/i ...
- mysql中实现字符串分割sp_split
sp_split : DELIMITER $$ CREATE DEFINER = 'test_user'@'%' PROCEDURE sp_split (IN p_str varchar(2000 ...
- easyui的datagrid和treegrid的使用
$('#listTree').treegrid({ idField: 'id', treeField: 'menuName', columns: [[ { title: 'Task Name', fi ...
- keras 设置GPU使用率
import tensorflow as tffrom keras.backend.tensorflow_backend import set_session config = tf.ConfigP ...