安装好nginx,php环境后,配置虚拟主机,结果访问后就报502 gateway,查看日志文件后,显示错误如下:

2019/04/29 16:24:39 [error] 19433#19433: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.1.52, server: 192.168.1.222, request: "GET / HTTP/1.1"

解决方案,先查看下php-fpm是否启动,然后查看虚拟主机配置中的 root 配置

server {
listen 80;
server_name 192.168.1.222; charset utf-8; location / {
root /data/wwwroot;
index index.php index.html index.htm;
} location ~ \.php$ {
#注意这里root配置与当前server下的root保持一致
#我的报错原因是我把root这项给删除
root /data/wwwroot;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

然后重启下nginx就可以访问了。

nginx访问502 gateway,*1 connect() failed (111: Connection refused) while connecting to upstream的更多相关文章

  1. 配置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 ...

  2. nginx 报错 connect() failed (111: Connection refused) while connecting to upstream

    公司网站搬迁到新服务器后,发现站点访问不了,network里面提示502,查看相关的server配置,感觉没有什么问题,经过测试发现txt.html.等非php文件能够直接访问,也就是php访问不了, ...

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

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

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

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

  5. [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 ...

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

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

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

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

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

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

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

    遇到这种情况, 首先 1.检查php-fpm是否启动---------如果没启动->启动, 2.用命令 netstat -ant | grep 9000 查看php-fpm进程,如果没启动-&g ...

随机推荐

  1. Why Lua?

    Why Lua? 最近在很多的地方都遇到了lua这个东西,于是想一探究竟,为什么这么多的游戏前端都用了Lua脚本呢? 于是乎简单的看了一下Lua,目前总结出来了几点~ 还是先放上资源: GitHub上 ...

  2. 使用 Angular Console 提升开发体验

    Angular Console Angular Console 是一个用于扩展 Angular CLI 的强大工具,通过提供一个图形界面的形式,方便开发者使用 CLI 的功能. Angular CLI ...

  3. An error occurred while starting the application.

    一..net core 发布后的站点启动报错如下 An error occurred while starting the application. .NET Core 4.6.26328.01 X6 ...

  4. 记一次使用getRequestDispatcher遇到的坑。。响应页面出现新建下载任务

    getRequestDispatcher RequestDispatcher接口提供将请求转发送到另一个资源的功能,它可能是html,servlet或jsp等. 此接口也可用于包括另一资源的内容.它是 ...

  5. C++_数字时钟

    利用C++语言基础,制作了一个模拟电子时钟的程序. #include<iostream> #include<windows.h> //延时与清屏头文件 using namesp ...

  6. java idea 代码规范插件

    推荐阿里的 p3c https://github.com/alibaba/p3c

  7. New York is 3 hours ahead of California

    New York is 3 hours ahead of California, 纽约时间比加州时间早三个小时, but it does not make California slow. 但加州时间 ...

  8. centos 7安装vnc服务端&vnc客户端连接

    前言 工作需求,需要用到vnc,介绍一下相关内容. 安装vnc服务端 在执行其他相关的之前,需要先安装一下vnc的服务端,命令如下: yum install tigervnc-server 配置vnc ...

  9. 我的coding地址

    https://dev.tencent.com/u/dtid_d6b0780bdefc3f9c/follower#1

  10. node note

    1.关于next() next()函数接受一个Error对象,在判断错误时,返回这个next()函数,并传入自定义的Error对象可以被向下捕捉,你也可以自定义统一捕捉错误Error的中间件,在app ...