LNMP时,出现502 Bad Gateway的错误提示
来源:互联网 发布:软件项目沟通机制 编辑:程序博客网 时间:2024/06/06 19:06
因为工作需要,要在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的错误提示
- lnmp安装包出现Nginx 502 Bad Gateway错误解决方案
- lnmp升级php出现502 bad gateway错误
- NGINX转发出现502 BAD GATEWAY的错误
- 关于lnmp一键安装包的nginx 502 Bad Gateway错误
- LNMP一键安装包的Nginx 502 Bad Gateway错误可能原因及解决方法
- LNMP一键安装包的Nginx 502 Bad Gateway错误可能原因及解决方法
- nginx 下 thinkphp 502 bad Gateway + "LNMP一键安装包的Nginx 502 Bad Gateway错误可能原因及解决方法"
- lnmp一键包502 Bad Gateway彻底的解决方法
- LNMP : 502 Bad Gateway 解决小记,真正的原因
- Nginx 502 Bad Gateway错误的解决办法
- LNMP 常见502 Bad Gateway问题汇总
- PHPStorm 提示502 Bad Gateway
- nginx+php-fpm出现502 bad gateway错误解决方法
- nginx+php-fpm出现502 bad gateway错误解决方法
- nginx+php-fpm出现502 bad gateway错误解决方法
- nginx+php-fpm出现502 bad gateway错误解决方法
- nginx+php-fpm出现502 bad gateway错误解决方法
- 单调队列初步
- 自己实现一个简单的ftp软件
- CSS盒模型
- spring booot多环境配置
- 【React Native】Mac端iOS和Android开发环境搭建完全教程
- LNMP时,出现502 Bad Gateway的错误提示
- Apache Kylin构建cube的FactDistinctColumnsJob阶段出现IllegalStateException异常
- web页面a标签触发事件
- 15分钟搭建独立电子书博客
- JAVA-WEB Hibernate面试整理
- 结构体及位段
- 三极管基极偏置电路原理应用于继电器的驱动电路的分析
- Markdown
- go语言使用redis —— redigo