<?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/314/</link>
<title><![CDATA[Nginx 0.5.33 + PHP 5.2.5（FastCGI）搭建胜过Apache 10倍的Web服务器（第2版）[原创]]]></title> 
<author>张宴 &lt;net@s135.com&gt;</author>
<category><![CDATA[Web服务器]]></category>
<pubDate>Mon, 03 Dec 2007 10:31:20 +0000</pubDate> 
<guid>http://zyan.cc/post/314/</guid> 
<description>
<![CDATA[ 
	　　<strong><span style="font-size: 14px;"><span style="color: #FF0000;">本文已有最新版本：</span></span></strong><br/><br/>　　<strong><span style="font-size: 14px;"><span style="color: #FF0000;">请点击</span>《<a href="http://blog.zyan.cc/nginx_php_v6/" target="_blank">Nginx 0.8.x + PHP 5.2.13（FastCGI）搭建胜过Apache十倍的Web服务器（第6版）</a>》</span></strong><br/><br/><hr/><br/><br/>　　[文章作者：张宴 本文版本：v2.1 最后修改：<span style="color: #FF0000;">2008.02.27</span> 转载请注明出处：<a href="http://blog.zyan.cc" target="_blank">http://blog.zyan.cc</a>]<br/><br/>　　前言：本文为我2007年9月写过的文章《<a href="read.php/297.htm" target="_blank">Nginx 0.5.31 + PHP 5.2.4（FastCGI）搭建可承受3万以上并发连接数，胜过Apache 10倍的Web服务器</a>》的第2版，经过了多台服务器的测试，修正了PHP iconv和gd库冲突的BUG，增加了PHP mcrypt、memcache扩展，修改了PHP和Nginx编译参数，优化了Nginx配置文件，添加了部分功能。<br/><br/>　　<a href="http://www.nginx.net/" target="_blank">Nginx</a> ("engine x") 是一个高性能的 HTTP 和反向代理服务器，也是一个 IMAP/POP3/SMTP 代理服务器。 Nginx 是由 Igor Sysoev 为俄罗斯访问量第二的 Rambler.ru 站点开发的，它已经在该站点运行超过两年半了。Igor 将源代码以类BSD许可证的形式发布。<br/><br/>　　Nginx 的中文维基：<a href="http://wiki.codemongers.com/NginxChs" target="_blank">http://wiki.codemongers.com/NginxChs</a><br/><br/><hr/><br/>　　在高并发连接的情况下，Nginx是Apache服务器不错的替代品。Nginx同时也可以作为7层负载均衡服务器来使用。根据我的测试结果，<strong>Nginx 0.5.33 + PHP 5.2.5 (FastCGI) 可以承受3万以上的并发连接数，相当于同等环境下Apache的10倍</strong>。<br/><br/>　　根据我的经验，4GB内存的服务器+Apache（prefork模式）一般只能处理3000个并发连接，因为它们将占用3GB以上的内存，还得为系统预留1GB的内存。我曾经就有两台Apache服务器，因为在配置文件中设置的MaxClients为4000，当Apache并发连接数达到3800时，导致服务器内存和Swap空间用满而崩溃。<br/><br/>　　而这台 Nginx 0.5.33 + PHP 5.2.5 (FastCGI) 服务器在3万并发连接下，开启的10个Nginx进程消耗150M内存（15M*10=150M），开启的64个php-cgi进程消耗1280M内存（20M*64=1280M），加上系统自身消耗的内存，总共消耗不到2GB内存。如果服务器内存较小，完全可以只开启25个php-cgi进程，这样php-cgi消耗的总内存数才500M。<br/><br/>　　在3万并发连接下，访问Nginx 0.5.33 + PHP 5.2.5 (FastCGI) 服务器的PHP程序，仍然速度飞快。下图为Nginx的状态监控页面，显示的活动连接数为28457（关于Nginx的监控页配置，会在本文接下来所给出的Nginx配置文件中写明）：<br/><br/>　　<a href="http://zyan.cc/attachment/200712/nginx_status.png" target="_blank"><img src="http://zyan.cc/attachment/200712/nginx_status.png" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a><br/><br/>　　以下为 Nginx 0.5.33 + PHP 5.2.5 (FastCGI) 服务器在3万并发连接下，开启的10个Nginx进程和64个php-cgi进程时的系统负载情况：<br/><br/>　　<a href="http://zyan.cc/attachment/200712/nginx_top.gif" target="_blank"><img src="http://zyan.cc/attachment/200712/nginx_top.gif" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a><br/><br/><hr/><br/>　　安装步骤：<br/>　　（系统要求：Linux 2.6+ 内核，本文中的Linux操作系统为CentOS 4.4）<br/><br/>　　一、获取相关开源程序：<br/>　　1、下载程序源码包到当前目录：<br/>　　本文中提到的所有开源软件为截止到2007年11月25日的最新稳定版。我将它们打了两个压缩包。<br/><br/>............<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>
]]>
</description>
</item><item>
<link>http://zyan.cc/post/314/#blogcomment482</link>
<title><![CDATA[[评论] Nginx 0.5.33 + PHP 5.2.5（FastCGI）搭建胜过Apache 10倍的Web服务器（第2版）[原创]]]></title> 
<author>axpwx &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 06 Dec 2007 08:16:40 +0000</pubDate> 
<guid>http://zyan.cc/post/314/#blogcomment482</guid> 
<description>
<![CDATA[ 
	持怀疑态度...
]]>
</description>
</item><item>
<link>http://zyan.cc/post/314/#blogcomment490</link>
<title><![CDATA[[评论] Nginx 0.5.33 + PHP 5.2.5（FastCGI）搭建胜过Apache 10倍的Web服务器（第2版）[原创]]]></title> 
<author>minuteman &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 07 Dec 2007 10:04:48 +0000</pubDate> 
<guid>http://zyan.cc/post/314/#blogcomment490</guid> 
<description>
<![CDATA[ 
	不错，以后有机会实验一下，不过我对php和mysql不太熟悉，以前别人做在那里的系统要重新编译，心里没底。呵呵
]]>
</description>
</item><item>
<link>http://zyan.cc/post/314/#blogcomment491</link>
<title><![CDATA[[评论] Nginx 0.5.33 + PHP 5.2.5（FastCGI）搭建胜过Apache 10倍的Web服务器（第2版）[原创]]]></title> 
<author>sx98083714 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sat, 08 Dec 2007 01:38:30 +0000</pubDate> 
<guid>http://zyan.cc/post/314/#blogcomment491</guid> 
<description>
<![CDATA[ 
	实在是佩服呀！<br/>文章写的实在是太好了，有理有据还很详细。惭愧呀，我会经常到这里看看的，希望能永远和张宴老师共同进步呀！
]]>
</description>
</item><item>
<link>http://zyan.cc/post/314/#blogcomment494</link>
<title><![CDATA[[评论] Nginx 0.5.33 + PHP 5.2.5（FastCGI）搭建胜过Apache 10倍的Web服务器（第2版）[原创]]]></title> 
<author>2J &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sun, 09 Dec 2007 07:45:37 +0000</pubDate> 
<guid>http://zyan.cc/post/314/#blogcomment494</guid> 
<description>
<![CDATA[ 
	实际中不会有这么大的差异，因为还要考虑mysql的影响。
]]>
</description>
</item><item>
<link>http://zyan.cc/post/314/#blogcomment511</link>
<title><![CDATA[[评论] Nginx 0.5.33 + PHP 5.2.5（FastCGI）搭建胜过Apache 10倍的Web服务器（第2版）[原创]]]></title> 
<author>Nanu &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Tue, 18 Dec 2007 06:56:30 +0000</pubDate> 
<guid>http://zyan.cc/post/314/#blogcomment511</guid> 
<description>
<![CDATA[ 
	......<br/>pid /usr/local/nginx/var/nginx.pid;<br/>......<br/><br/>kill -HUP &#96;cat /usr/local/nginx/var/nginx.pid&#96;
]]>
</description>
</item><item>
<link>http://zyan.cc/post/314/#blogcomment516</link>
<title><![CDATA[[评论] Nginx 0.5.33 + PHP 5.2.5（FastCGI）搭建胜过Apache 10倍的Web服务器（第2版）[原创]]]></title> 
<author>bighearted &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 19 Dec 2007 10:52:08 +0000</pubDate> 
<guid>http://zyan.cc/post/314/#blogcomment516</guid> 
<description>
<![CDATA[ 
	这个不能在windows下装吗？
]]>
</description>
</item><item>
<link>http://zyan.cc/post/314/#blogcomment519</link>
<title><![CDATA[[评论] Nginx 0.5.33 + PHP 5.2.5（FastCGI）搭建胜过Apache 10倍的Web服务器（第2版）[原创]]]></title> 
<author>小米 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 20 Dec 2007 01:29:50 +0000</pubDate> 
<guid>http://zyan.cc/post/314/#blogcomment519</guid> 
<description>
<![CDATA[ 
	请教张老师，MySQL怎么样实现，一主多从，仍后读写分离的呢？这个读写分离是怎么样实现的呢？性能怎么样？
]]>
</description>
</item><item>
<link>http://zyan.cc/post/314/#blogcomment524</link>
<title><![CDATA[[评论] Nginx 0.5.33 + PHP 5.2.5（FastCGI）搭建胜过Apache 10倍的Web服务器（第2版）[原创]]]></title> 
<author>IceskYsl &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 21 Dec 2007 04:46:28 +0000</pubDate> 
<guid>http://zyan.cc/post/314/#blogcomment524</guid> 
<description>
<![CDATA[ 
	nginx的效率确实很好，就我在rails方面的测试也可以看出；<br/>nginx代理转发到backend的mogrel，效率实在不错。。<br/><br/>多谢您分析在PHP方面的配置。。
]]>
</description>
</item><item>
<link>http://zyan.cc/post/314/#blogcomment533</link>
<title><![CDATA[[评论] Nginx 0.5.33 + PHP 5.2.5（FastCGI）搭建胜过Apache 10倍的Web服务器（第2版）[原创]]]></title> 
<author>asd123 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Tue, 25 Dec 2007 02:34:28 +0000</pubDate> 
<guid>http://zyan.cc/post/314/#blogcomment533</guid> 
<description>
<![CDATA[ 
	apmserv怎么都不更新了<br/><br/>挺好用的软件
]]>
</description>
</item><item>
<link>http://zyan.cc/post/314/#blogcomment540</link>
<title><![CDATA[[评论] Nginx 0.5.33 + PHP 5.2.5（FastCGI）搭建胜过Apache 10倍的Web服务器（第2版）[原创]]]></title> 
<author>JulyClyde &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 28 Dec 2007 06:34:11 +0000</pubDate> 
<guid>http://zyan.cc/post/314/#blogcomment540</guid> 
<description>
<![CDATA[ 
	为什么这么多东西都现场编译呢？<br/>我觉得除了nginx这类太新的、频繁变动中的软件以外，其它的像php啥的直接装个包就可以了，能节省很多时间<br/><br/>大量编译软件，会造成这台机器上到底装了哪些软件只有你一个人知道，不方便移交机器给别人使用。
]]>
</description>
</item><item>
<link>http://zyan.cc/post/314/#blogcomment541</link>
<title><![CDATA[[评论] Nginx 0.5.33 + PHP 5.2.5（FastCGI）搭建胜过Apache 10倍的Web服务器（第2版）[原创]]]></title> 
<author>chrisma &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sat, 29 Dec 2007 00:36:13 +0000</pubDate> 
<guid>http://zyan.cc/post/314/#blogcomment541</guid> 
<description>
<![CDATA[ 
	为什么不采用freebsd呢？什么时候张老师也写篇freebsd+nginx呢？
]]>
</description>
</item><item>
<link>http://zyan.cc/post/314/#blogcomment544</link>
<title><![CDATA[[评论] Nginx 0.5.33 + PHP 5.2.5（FastCGI）搭建胜过Apache 10倍的Web服务器（第2版）[原创]]]></title> 
<author>kkan &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sun, 30 Dec 2007 07:47:11 +0000</pubDate> 
<guid>http://zyan.cc/post/314/#blogcomment544</guid> 
<description>
<![CDATA[ 
	按上面的文章安装成功。庆贺！<br/>但也发现了几个问题。<br/>第一。不知道作者的centos都安装了哪些功能模块。我是最小化安装，仅安装了开发工具，在进行中发现有很多错误，在线yum了多个模块之后安装成功。<br/>第二。mysql不能随系统启动。进入系统后只有通过/bin/sh /usr/local/webserver/mysql/bin/mysqld_safe --defaults-file=/usr/local/webserver/mysql/my.cnf &amp;命令两次运行，才能启动mysql。service命令不能关闭和启动mysql。不知道这个是不是我个人独有的错误。希望作者检查改进。<br/>第三。希望作者能将虚拟主机的配置和系统安全方面的设置做多些说明。<br/>谢谢！
]]>
</description>
</item><item>
<link>http://zyan.cc/post/314/#blogcomment551</link>
<title><![CDATA[[评论] Nginx 0.5.33 + PHP 5.2.5（FastCGI）搭建胜过Apache 10倍的Web服务器（第2版）[原创]]]></title> 
<author>痴男 &lt;yjzq999@163.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 04 Jan 2008 03:55:07 +0000</pubDate> 
<guid>http://zyan.cc/post/314/#blogcomment551</guid> 
<description>
<![CDATA[ 
	6275#0: getpwnam(&quot;www&quot;) failed in /usr/local/webserver/nginx/conf/nginx.conf:1<br/><br/>我的出现这个怎么办啊<br/>对我说一下WWW目录怎么了<br/>没有创建好还是怎么了
]]>
</description>
</item><item>
<link>http://zyan.cc/post/314/#blogcomment552</link>
<title><![CDATA[[评论] Nginx 0.5.33 + PHP 5.2.5（FastCGI）搭建胜过Apache 10倍的Web服务器（第2版）[原创]]]></title> 
<author>痴男 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 04 Jan 2008 04:35:17 +0000</pubDate> 
<guid>http://zyan.cc/post/314/#blogcomment552</guid> 
<description>
<![CDATA[ 
	有谁知道路过的说一下啊<br/>我都是按照他说的那样装的，前面一直没有出现过什么问题<br/>我安装的系统是LINUX AS5<br/>会是系统问题吗
]]>
</description>
</item><item>
<link>http://zyan.cc/post/314/#blogcomment556</link>
<title><![CDATA[[评论] Nginx 0.5.33 + PHP 5.2.5（FastCGI）搭建胜过Apache 10倍的Web服务器（第2版）[原创]]]></title> 
<author>rickyfang &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sun, 06 Jan 2008 05:38:41 +0000</pubDate> 
<guid>http://zyan.cc/post/314/#blogcomment556</guid> 
<description>
<![CDATA[ 
	Configuring extensions<br/>checking whether to enable LIBXML support... yes<br/>checking libxml2 install dir... yes<br/>checking for xml2-config path... /usr/local/bin/xml2-config<br/>checking whether libxml build works... no<br/>configure: error: build test failed. &nbsp;Please check the config.log for details.<br/><br/>照着做，在CENTOS上。但总是出这个问题。
]]>
</description>
</item>
</channel>
</rss>