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: itkylin.com, request: "GET /wp-login.php?action=logout&_wpnonce=f012fbea93 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "itkylin.com", referrer: "http://itkylin.com/wp-admin/profile.php"
解决方案:
增加
fastcgi_buffer_size 128k;
fastcgi_buffers 32 32k;
client_body_buffer_size 1024k;
两行到网站定义的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;
client_body_buffer_size 1024k;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
:wq!
然后重启nginx服务即可。
service nginx restart
service php5-fpm restart
ps:也可在nginx.conf加上以下参数。
client_body_buffer_size 1024k;