解决nginx报错:502 Bad Gateway以及504 Gateway Time-out问题

网站建设评论2,052阅读模式
摘要

wordpress及宝塔面板的基本环节,出现nginx错误:502 Bad Gateway 502 Bad Gateway以及504 Gateway Time-out 504 Gateway Time-out问题后的解决办法。

解决nginx报错:502 Bad Gateway以及504 Gateway Time-out问题

 

wordprss安装插件或者上传大文件时,总是时不时出现这个问题。

错误——502 Bad Gateway 502 Bad Gateway nginx

安装失败: 502 Bad Gateway 502 Bad Gateway nginx <!-- a padding to disable MSIE and Chrome friendly error page --> <!-- a padding to disable MSIE and Chrome friendly error page --> <!-- a padding to disable MSIE and Chrome friendly error page --> <!-- a padding to disable MSIE and Chrome friendly error page --> <!-- a padding to disable MSIE and Chrome friendly error page --> <!-- a padding to disable MSIE and Chrome friendly error page -->

如图所示

解决nginx报错:502 Bad Gateway以及504 Gateway Time-out问题

解决方法:

参考(看了很多解决问题的文章,这篇分析的够透彻)

http://www.360doc.com/content/16/0105/17/12146850_525690022.shtml

vi /www/server/php/74/etc/php-fpm.conf

修改前文件配置

[global]
pid = /www/server/php/74/var/run/php-fpm.pid
error_log = /www/server/php/74/var/log/php-fpm.log
log_level = notice
[www]
listen = /tmp/php-cgi-74.sock
listen.backlog = 8192
listen.allowed_clients = 127.0.0.1
listen.owner = www
listen.group = www
listen.mode = 0666
user = www
group = www
pm = dynamic
pm.status_path = /phpfpm_74_status
pm.max_children = 150
pm.start_servers = 10
pm.min_spare_servers = 10
pm.max_spare_servers = 30
request_terminate_timeout = 100
request_slowlog_timeout = 30
slowlog = var/log/slow.log

修改request_terminate_timeout = 600

重启php

再安装插件,感觉没那么快出错,怀疑是安装插件时间段内网络不好,毕竟是在插件在国外。

然而这次出现的是504错误。

错误——504 Gateway Time-out 504 Gateway Time-out nginx

安装失败: 504 Gateway Time-out 504 Gateway Time-out nginx <!-- a padding to disable MSIE and Chrome friendly error page --> <!-- a padding to disable MSIE and Chrome friendly error page --> <!-- a padding to disable MSIE and Chrome friendly error page --> <!-- a padding to disable MSIE and Chrome friendly error page --> <!-- a padding to disable MSIE and Chrome friendly error page --> <!-- a padding to disable MSIE and Chrome friendly error page -->

解决nginx报错:502 Bad Gateway以及504 Gateway Time-out问题

修改配置文件nginx.conf

修改前配置

fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;

调大这两个参数,修改后为:

fastcgi_buffer_size 128k;
fastcgi_buffers 8 128k;

重启nginx

完美解决!

linux新磁盘分区操作 Linux

linux新磁盘分区操作

新加一块磁盘进行分区,步骤如下。 查看 查看磁盘及分区 lsblk 查看磁盘详细分区情况 fdisk -l 建立分区 建立磁盘主分区 采用这种方式,两个分区都设为主分区 fdisk /dev/sdb ...