LNMP时,出现502 Bad Gateway的错误提示
因为工作需要,要在ubuntu中安装LNMP环境,在这里,php是最新版本php7.1。一切都进展得很顺利,安装完成后,在浏览器中输入http://127.0.0.1/info.php,出现了502 Bad Gateway的错误提示。
打开/var/log/nginx 下的error.log,发现提示为:2017/07/15 14:46:47 [error] 1228#0: *8 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET /info.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000",
host: "127.0.0.1"。
进入/etc/php/7.1/fpm/pool.d下,打开www.conf文件,找到listen这一行,发现listen = /run/php/php7.1-fpm.sock。(我的php7.1-fpm.sock 在/var/run/php/php7.1-fpm.sock下,于是改成了/var/run/php/php7.1-fpm.sock)
进入/etc/nginx/sites-available目录下,打开default文件,里面的location配置为:
location ~ \.php$ {
# fastcgi_split_path_info ^(.+\.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
# fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
# include fastcgi_params;
# fastcgi_index index.php;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
}
很明显,default文件中的l监听方式和www.conf文件中的不一样,因此我改为:
location ~ \.php$ {
# fastcgi_split_path_info ^(.+\.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_index index.php;
include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
}
最终default文件如下:
保存这个配置后,重启Nginx ;service nginx restart,然后刷新浏览器,最后的结果展示如下:
问题得到了解决!
LNMP时,出现502 Bad Gateway的错误提示的更多相关文章
- nginx显示静态html爆502 bad gateway的错误提示
在centos的服务器上,没有启动php-fcgi. 本来是想设置显示一个静态文件目录的,用不着php,于是就关闭了php-fcgi. 结果打开爆了一个大大的nginx502 bad gateway的 ...
- Nginx 502/504 Gateway time-out错误完美解决方案【转发】
在安装完Nginx+PHP-fpm+Mysql后,跑PHP的应用会经常出现504 Gateway Time-out 或者502 Bad Gateway的情况. Nginx 504 Gateway ...
- Nginx 502 Bad Gateway 的错误的解决方案
我用的是nginx反向代理Apache,直接用Apache不会有任何问题,加上nginx就会有部分ajax请求502的错误,下面是我收集到的解决方案. 一.fastcgi缓冲区设置过小 出现错误,首先 ...
- nginx+php测试时显示 502 bad gateway的解决方法
http://www.apelearn.com/study_v2/chapter18.html 由于阿铭老师的PHP版本是 5.3的 我装了 5.5 测试出现了 502 错误 查看日志 借助 ...
- JSP中,当页面为404或者500时。设置跳转到错误提示页面
最好的就是在WEB.XML文件中配置错误代码的跳转页面,首先建立个 出现500错误的页面,提示出错了,然后再WEB.XML文件中配置,配置如下 一. 通过错误码来配置error-page <er ...
- Process启动.exe,当.exe内部抛出异常时,总会弹出一个错误提示框,阻止Process进入结束
public class TaskProcess { [DllImport("kernel32.dll", SetLastError = true)] public static ...
- 在使用HTMLTestRunner时,报告为空,错误提示<_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf_8'>
<_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf_8'> Time Elapsed: 0:00:21.3163 ...
- 记一次nginx部署yii2项目时502 bad gateway错误的排查
周六闲来无事,就试着安装和部署下yii2,安装过程没什么问题,但部署到nginx上时遇到了502 bad gatewary问题,折腾了半天才搞定.这个问题是我以前在部署yii2时没有遇到过的,因此记在 ...
- LNMP环境出现”504 gateway time-out”错误的解决方案
今天下午在调试测试VPS机器的时候,出现"504 gateway time-out"错误提示.VPS是安装的LNMP一键安装包,关于这个错误之前还没有见过,网上看到比较多的是502 ...
随机推荐
- Python爬虫入门项目
Python是什么 Python是著名的"龟叔"Guido van Rossum在1989年圣诞节期间,为了打发无聊的圣诞节而编写的一个编程语言. 创始人Guido van Ros ...
- MySQL系列--2.常用的命令
1 .创建数据库 #语法: CREATE DATABASE dbName; #创建数据库rms create database rms; 2.切换数据库 #选择数据库 USE dbName; #选择数 ...
- Chapter 4 Invitations——22
"Are you going all by yourself?" he asked, and I couldn't tell if he was suspicious I had ...
- ThreadPoolExecutor系列二——ThreadPoolExecutor 代码流程图
ThreadPoolExecutor 代码流程图 本文系作者原创,转载请注明出处:http://www.cnblogs.com/further-further-further/p/7681648.ht ...
- 深入理解C#中的IDisposable接口
写在前面 在开始之前,我们需要明确什么是C#(或者说.NET)中的资源,打码的时候我们经常说释放资源,那么到底什么是资源,简单来讲,C#中的每一种类型都是一种资源,而资源又分为托管资源和非托管资源,那 ...
- leetcode — triangle
/** * Source : https://oj.leetcode.com/problems/triangle/ * * * Given a triangle, find the minimum p ...
- 第34章 授予类型 - Identity Server 4 中文文档(v1.0.0)
授权类型是指定客户端如何与IdentityServer交互的方式.OpenID Connect和OAuth2.0规范定义了以下授权类型: Implicit Authorization code Hyb ...
- Node.js 应用:Koa2 使用 JWT 进行鉴权
前言 在前后端分离的开发中,通过 Restful API 进行数据交互时,如果没有对 API 进行保护,那么别人就可以很容易地获取并调用这些 API 进行操作.那么服务器端要如何进行鉴权呢? Json ...
- 第一册:lesson 105.
原文: Full of mistakes. Where's Sandra,Bob? I want her. Do you want to speak to her? Yes I do. I want ...
- [PHP] 工厂模式的日常使用
负责生成其他对象的类或方法,这就是工厂模式,下面是一个经常见到的用法 <?php class test{ public $x=1; public $setting; //负责生成其他对象的类或方 ...