Nginx环境下的wordpress退出时提示502错误的解决办法

Nginx环境下的wordpress退出时提示:”502 bad gateway”错误,查看nginx的log记录tail -f /var/log/nginx/error.log出现如下错误信息:

2017/05/05 15:39:35 [error] 16740#0: *2239 upstream sent too big header while reading response header from upstream, client: 112.xxx.16.16, server: service-labs.com, request: "GET /wp-login.php?action=logout&_wpnonce=f012fbea93 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "service-labs.com", referrer: "http://service-labs.com/wp-admin/profile.php"

解决方案:
增加
fastcgi_buffer_size 128k;
fastcgi_buffers 32 32k;

两行到网站定义的location ~ \.php$部份,如下例:
vi /etc/nginx/sites-available/default
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_buffer_size 128k;
fastcgi_buffers 32 32k;

fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}

:wq!
然后重启nginx服务即可。
service nginx restart
service php5-fpm restart

原文链接:,转发请注明来源!

发表评论