PHP程序出现 出现 502 bad gateway 如何破?

WBOY
Release: 2016-06-06 20:39:41
Original
1989 people have browsed it

PHP程序出现 出现 502 bad gateway 如何破?

回复内容:

PHP程序出现 出现 502 bad gateway 如何破?

确认php-fpm进程正常,然后从运行环境入手,调整超时和缓冲区大小配置。

例如一个 iptables + haproxy + nginx + php-fpm 运行环境,haproxy和nginx都可能触发502,或许是你的php运行时间超出了haproxy或nginx的超时设置,或许是你的php输出了大量的cookie数据等等。

nginx.conf参考调整

<code># 502 probolem solving
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 8 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors off;
</code>
Copy after login

haproxy.cfg参考调整

<code>tune.bufsize 131072
</code>
Copy after login

PHP不会报502的 一定是你的前端web服务器(如nginx, Apache)报的502错误

出现这种错误一般是你的前端web服务器无法连接后端cgi(如php-fpm)造成的

进一步的原因,就是fpm挂了,或者卡死了(并发高、内存或者CPU不够用的时候就会出现)

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template