<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[张宴的博客]]></title> 
<link>http://zyan.cc/index.php</link> 
<description><![CDATA[Web系统架构与底层研发]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[张宴的博客]]></copyright>
<item>
<link>http://zyan.cc/post/361/</link>
<title><![CDATA[解决Nginx  + PHP（FastCGI）遇到的502 Bad Gateway错误[原创]]]></title> 
<author>张宴 &lt;net@s135.com&gt;</author>
<category><![CDATA[Web服务器]]></category>
<pubDate>Tue, 29 Jul 2008 23:09:55 +0000</pubDate> 
<guid>http://zyan.cc/post/361/</guid> 
<description>
<![CDATA[ 
	　　[文章作者：张宴 本文版本：v1.0 最后修改：2008.07.30 转载请注明原文链接：<a href="http://blog.zyan.cc/read.php/361/" target="_blank">http://blog.zyan.cc/read.php/361/</a>]<br/><br/>　　昨日，有朋友问我，他将Web服务器换成Nginx 0.6.31&nbsp;&nbsp;+ PHP 4.4.7（FastCGI）后，有时候访问会出现“502 Bad Gateway”错误，如何解决。<br/><br/>　　我让按照以下两个步骤去解决，最后在第2步中将FastCGI的timeout时间增加为300，问题解决：<br/><br/>　　PS：比较羡慕迅雷的Web服务器，16G内存。<br/><br/><hr/><br/>　　1、查看当前的PHP FastCGI进程数是否够用：<br/><div style="border-left: 0px dashed #D6C094; margin: 5px; padding: 3px; margin-bottom:0px; border: 1px dashed #00a0c6; background-color: #ffffff;">netstat -anpo &#124; grep "php-cgi" &#124; wc -l</div><br/>　　如果实际使用的“FastCGI进程数”接近预设的“FastCGI进程数”，那么，说明“FastCGI进程数”不够用，需要增大。<br/><br/><hr/><br/>　　2、部分PHP程序的执行时间超过了Nginx的等待时间，可以适当增加nginx.conf配置文件中FastCGI的timeout时间，例如：<br/><div style="border-left: 0px dashed #D6C094; margin: 5px; padding: 3px; margin-bottom:0px; border: 1px dashed #00a0c6; background-color: #ffffff;">......<br/>http <br/>&#123;<br/>......<br/>fastcgi_connect_timeout 300;<br/>fastcgi_send_timeout 300;<br/>fastcgi_read_timeout 300;<br/>......<br/>&#125;<br/>......</div><br/><br/>Tags - <a href="http://zyan.cc/tags/linux/" rel="tag">linux</a> , <a href="http://zyan.cc/tags/php/" rel="tag">php</a> , <a href="http://zyan.cc/tags/nginx/" rel="tag">nginx</a> , <a href="http://zyan.cc/tags/fastcgi/" rel="tag">fastcgi</a> , <a href="http://zyan.cc/tags/http/" rel="tag">http</a>
]]>
</description>
</item><item>
<link>http://zyan.cc/post/361/#blogcomment1375</link>
<title><![CDATA[[评论] 解决Nginx  + PHP（FastCGI）遇到的502 Bad Gateway错误[原创]]]></title> 
<author>jacky &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 30 Jul 2008 01:02:24 +0000</pubDate> 
<guid>http://zyan.cc/post/361/#blogcomment1375</guid> 
<description>
<![CDATA[ 
	不太理解：<br/>netstat -an &#124; grep &quot;php-cgi&quot; &#124; wc -l<br/><br/>netstat -an 不是显示端口， grep php-cgi 能得到什么？<br/># netstat -an &#124; grep &quot;php-cgi&quot; &#124; wc -l<br/>0
]]>
</description>
</item><item>
<link>http://zyan.cc/post/361/#blogcomment1376</link>
<title><![CDATA[[评论] 解决Nginx  + PHP（FastCGI）遇到的502 Bad Gateway错误[原创]]]></title> 
<author>lhwmzy &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 30 Jul 2008 01:08:47 +0000</pubDate> 
<guid>http://zyan.cc/post/361/#blogcomment1376</guid> 
<description>
<![CDATA[ 
	命令写错了吧
]]>
</description>
</item><item>
<link>http://zyan.cc/post/361/#blogcomment1377</link>
<title><![CDATA[[评论] 解决Nginx  + PHP（FastCGI）遇到的502 Bad Gateway错误[原创]]]></title> 
<author>gusingchen &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 30 Jul 2008 01:18:52 +0000</pubDate> 
<guid>http://zyan.cc/post/361/#blogcomment1377</guid> 
<description>
<![CDATA[ 
	1、502是php执行时间过长造成,有问题的话加大进程数也没用. &nbsp;２、web &nbsp;服务器没有必要这么大的内存吧。cpu消耗多些。
]]>
</description>
</item><item>
<link>http://zyan.cc/post/361/#blogcomment1380</link>
<title><![CDATA[[评论] 解决Nginx  + PHP（FastCGI）遇到的502 Bad Gateway错误[原创]]]></title> 
<author>wayne &lt;zzw@msn.cn&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 30 Jul 2008 03:06:05 +0000</pubDate> 
<guid>http://zyan.cc/post/361/#blogcomment1380</guid> 
<description>
<![CDATA[ 
	预先设置的FastCGI数,是不是就是php-fpm.conf里的max_children值
]]>
</description>
</item><item>
<link>http://zyan.cc/post/361/#blogcomment1387</link>
<title><![CDATA[[评论] 解决Nginx  + PHP（FastCGI）遇到的502 Bad Gateway错误[原创]]]></title> 
<author>willko &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 31 Jul 2008 14:44:40 +0000</pubDate> 
<guid>http://zyan.cc/post/361/#blogcomment1387</guid> 
<description>
<![CDATA[ 
	方便面没打开也会出现这个错误。。。
]]>
</description>
</item><item>
<link>http://zyan.cc/post/361/#blogcomment1391</link>
<title><![CDATA[[评论] 解决Nginx  + PHP（FastCGI）遇到的502 Bad Gateway错误[原创]]]></title> 
<author>JulyClyde &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 01 Aug 2008 03:49:05 +0000</pubDate> 
<guid>http://zyan.cc/post/361/#blogcomment1391</guid> 
<description>
<![CDATA[ 
	504 Gateway Timeout才需要增加等待时间吧？<br/>502是Bad Gateway，是sock、端口没被监听造成的
]]>
</description>
</item><item>
<link>http://zyan.cc/post/361/#blogcomment1392</link>
<title><![CDATA[[评论] 解决Nginx  + PHP（FastCGI）遇到的502 Bad Gateway错误[原创]]]></title> 
<author>ww &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 01 Aug 2008 12:06:55 +0000</pubDate> 
<guid>http://zyan.cc/post/361/#blogcomment1392</guid> 
<description>
<![CDATA[ 
	老师有2个问题。。<br/>1.按照你的方法配置，，但是修改php.in 的display_errors = on。。用phpinfo()看还是off的。。。已经重启并且没改错php.ini文件<br/>2.请问下nginx怎么才能支持index.php/id/2这样的路径呢？<br/>我发现只支持index.php?/id/2<br/><br/>谢谢
]]>
</description>
</item><item>
<link>http://zyan.cc/post/361/#blogcomment1400</link>
<title><![CDATA[[评论] 解决Nginx  + PHP（FastCGI）遇到的502 Bad Gateway错误[原创]]]></title> 
<author>blankyao &lt;blankyao@gmail.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sun, 03 Aug 2008 15:44:57 +0000</pubDate> 
<guid>http://zyan.cc/post/361/#blogcomment1400</guid> 
<description>
<![CDATA[ 
	刚注册，我试下头像是否显示正常
]]>
</description>
</item><item>
<link>http://zyan.cc/post/361/#blogcomment1418</link>
<title><![CDATA[[评论] 解决Nginx  + PHP（FastCGI）遇到的502 Bad Gateway错误[原创]]]></title> 
<author>Dewei &lt;zdw163@hotmail.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sun, 10 Aug 2008 09:07:40 +0000</pubDate> 
<guid>http://zyan.cc/post/361/#blogcomment1418</guid> 
<description>
<![CDATA[ 
	large_client_header_buffers 4 32k;<br/>请问上次我问的时候，你回答的这样的，要不要再加了？
]]>
</description>
</item><item>
<link>http://zyan.cc/post/361/#blogcomment1427</link>
<title><![CDATA[[评论] 解决Nginx  + PHP（FastCGI）遇到的502 Bad Gateway错误[原创]]]></title> 
<author>wayne &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 14 Aug 2008 08:46:46 +0000</pubDate> 
<guid>http://zyan.cc/post/361/#blogcomment1427</guid> 
<description>
<![CDATA[ 
	nginx里的错误日志是不是不记录 502错误的,我没有发现呀
]]>
</description>
</item><item>
<link>http://zyan.cc/post/361/#blogcomment1429</link>
<title><![CDATA[[评论] 解决Nginx  + PHP（FastCGI）遇到的502 Bad Gateway错误[原创]]]></title> 
<author>dodoup &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 15 Aug 2008 09:19:13 +0000</pubDate> 
<guid>http://zyan.cc/post/361/#blogcomment1429</guid> 
<description>
<![CDATA[ 
	10309 daemon &nbsp; &nbsp;15 &nbsp; 0 7570m 2.7g &nbsp;812 S &nbsp; &nbsp;0 &nbsp;0.6 &nbsp; 0:02.63 nginx &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br/>10310 daemon &nbsp; &nbsp;15 &nbsp; 0 7552m 2.7g &nbsp;812 S &nbsp; &nbsp;0 &nbsp;0.6 &nbsp; 0:01.26 nginx &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br/>10313 daemon &nbsp; &nbsp;15 &nbsp; 0 75464 &nbsp;25m &nbsp;812 S &nbsp; &nbsp;0 &nbsp;0.6 &nbsp; 0:01.23 nginx &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br/>10318 daemon &nbsp; &nbsp;15 &nbsp; 0 7543m 2.7g &nbsp;812 S &nbsp; &nbsp;0 &nbsp;0.6 &nbsp; 0:01.31 nginx &nbsp; <br/><br/>有谁遇到过这样的问题米？
]]>
</description>
</item><item>
<link>http://zyan.cc/post/361/#blogcomment1439</link>
<title><![CDATA[[评论] 解决Nginx  + PHP（FastCGI）遇到的502 Bad Gateway错误[原创]]]></title> 
<author>wayne &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 20 Aug 2008 14:37:29 +0000</pubDate> 
<guid>http://zyan.cc/post/361/#blogcomment1439</guid> 
<description>
<![CDATA[ 
	兄弟,帮我看一下,nginx的日志,出现好多400的错误,这样是什么原因呢?<br/><br/>220.255.7.194 - - [20/Aug/2008:22:38:30 +0800] &quot;-&quot; 400 0 &quot;-&quot; &quot;-&quot; -<br/>60.190.0.78 - - [20/Aug/2008:22:38:31 +0800] &quot;-&quot; 400 0 &quot;-&quot; &quot;-&quot; -<br/>220.202.4.12 - - [20/Aug/2008:22:38:31 +0800] &quot;-&quot; 400 0 &quot;-&quot; &quot;-&quot; -<br/>220.202.4.12 - - [20/Aug/2008:22:38:31 +0800] &quot;-&quot; 400 0 &quot;-&quot; &quot;-&quot; -<br/>58.220.236.250 - - [20/Aug/2008:22:38:33 +0800] &quot;-&quot; 400 0 &quot;-&quot; &quot;-&quot; -<br/>117.40.118.93 - - [20/Aug/2008:22:38:33 +0800] &quot;-&quot; 400 0 &quot;-&quot; &quot;-&quot; -<br/>222.242.65.94 - - [20/Aug/2008:22:38:34 +0800] &quot;-&quot; 400 0 &quot;-&quot; &quot;-&quot; -<br/>58.220.236.250 - - [20/Aug/2008:22:38:34 +0800] &quot;-&quot; 400 0 &quot;-&quot; &quot;-&quot; -<br/>219.152.214.89 - - [20/Aug/2008:22:38:34 +0800] &quot;-&quot; 400 0 &quot;-&quot; &quot;-&quot; -<br/>58.33.12.209 - - [20/Aug/2008:22:38:35 +0800] &quot;-&quot; 400 0 &quot;-&quot; &quot;-&quot; -<br/>60.50.171.133 - - [20/Aug/2008:22:38:36 +0800] &quot;-&quot; 400 0 &quot;-&quot; &quot;-&quot; -
]]>
</description>
</item><item>
<link>http://zyan.cc/post/361/#blogcomment1449</link>
<title><![CDATA[[评论] 解决Nginx  + PHP（FastCGI）遇到的502 Bad Gateway错误[原创]]]></title> 
<author>jspshiwo &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 27 Aug 2008 15:15:29 +0000</pubDate> 
<guid>http://zyan.cc/post/361/#blogcomment1449</guid> 
<description>
<![CDATA[ 
	我刚新安装的 ngnix 就提示 502 Bad Gateway 错误 请问为什么啊 ？<br/> <br/> &nbsp;我用 netstat -anpo &#124; grep &quot;php-cgi&quot; &#124; wc -l &nbsp;查看你 显示 1
]]>
</description>
</item><item>
<link>http://zyan.cc/post/361/#blogcomment1581</link>
<title><![CDATA[[评论] 解决Nginx  + PHP（FastCGI）遇到的502 Bad Gateway错误[原创]]]></title> 
<author>uddtm &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Tue, 23 Sep 2008 11:46:26 +0000</pubDate> 
<guid>http://zyan.cc/post/361/#blogcomment1581</guid> 
<description>
<![CDATA[ 
	还是不行呀,我的/usr/local/webserver/php/bin/里边就没有php-cgi这个文件呀,我这样该怎样启动php-cgi进程<br/><br/>安装过程都正常,启动nginx后显示的也是502 Bad Gateway .
]]>
</description>
</item><item>
<link>http://zyan.cc/post/361/#blogcomment1735</link>
<title><![CDATA[[评论] 解决Nginx  + PHP（FastCGI）遇到的502 Bad Gateway错误[原创]]]></title> 
<author>weiwei &lt;shizhiweifly@163.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 24 Oct 2008 09:04:10 +0000</pubDate> 
<guid>http://zyan.cc/post/361/#blogcomment1735</guid> 
<description>
<![CDATA[ 
	502/504错误，改那个不顶用，而且PHP-CGI经常大片小时，网站很卡，一会又好了，感觉 <br/>php跑PHP-CGI很不稳定，快的时候真的很快，但慢起来就是 502、504<br/><br/><a href="http://bbs.woyool.com" target="_blank">http://bbs.woyool.com</a>
]]>
</description>
</item>
</channel>
</rss>