彻底解决Nginx 504 Gateway Time-out的一种途径[原创]
昨天刚装的LNMPZ一键安装包,今天调试参数的时候发现Nginxp频繁出现504 Gateway Time-out错误,也参阅了网上的文章,诸如做8组较大的 large_client_header_buffers 8 128k; 但是问题仍没有解决。
要彻底解决Nginx 504 Gateway Time-out,还得从源头分析产生Nginx 504 Gateway Time-out的原因。504 Gateway Time-out产生的主要原因是PHP脚本执行时间过长造成的。一方面是由于处理时的缓存不够大,这通常用网上所说的增加8组较大的缓存可以解决;另一方面则是PHP脚本自身的问题,导致死循环或者无法释放。解决该问题的方法则是让PHP有个最大的执行时间。
我的具体做法是在php-fpm.conf里修改最大请求时间,把默认的0s改成30s,即<value name=”request_terminate_timeout”>30s</value>
这样再重启php-cgi,问题解决。
I was just now searching around about this when I found your blog post. I’m only dropping by to say that I very much enjoyed seeing this post, it’s very well written. Are you planning topost more about this? It appears like there is more depth here for more posts.
I was just now searching around about this when I found your blog post. I’m simply stopping by to say that I really enjoyed seeing this post, it’s really clear and well written. Are you going to write more on this? It seems like there is more fodder here for future posts.
Hay G, are you seriously? The next time please use a neat title like your name, or I will consider it’s a ad… By the way, for Chinese we can’t open youtube.com website, because there is a big GFW in China. You can find it from wikipedia.
And I will surely update this blog with my pleasure.