<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Java堂 &#187; apache</title>
	<atom:link href="http://www.javatang.com/archives/tag/apache/feed" rel="self" type="application/rss+xml" />
	<link>http://www.javatang.com</link>
	<description>Java Tang</description>
	<lastBuildDate>Thu, 08 Dec 2011 08:29:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Apache2.x中设置gzip</title>
		<link>http://www.javatang.com/archives/2010/12/01/2805477.html</link>
		<comments>http://www.javatang.com/archives/2010/12/01/2805477.html#comments</comments>
		<pubDate>Wed, 01 Dec 2010 05:28:05 +0000</pubDate>
		<dc:creator>Jet</dc:creator>
				<category><![CDATA[Web&Server]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[gzip]]></category>

		<guid isPermaLink="false">http://www.javatang.com/?p=477</guid>
		<description><![CDATA[在Apache2.x中使用mod_deflate进行gzip压缩，配置信息如下： LoadModule deflate_module modules/mod_deflate.so LoadModule headers_module modules/mod_headers.so &#160; # gzip 设置 # Only compress specified content type # see also http://www.devside.net/guides/config/compression &#60;IfModule mod_deflate.c&#62; &#160;&#160; &#160;# The value must between 1 (less compression) and 9 (more compression) &#160;&#160; &#160;DeflateCompressionLevel 7 &#160;&#160; &#160;# compress content with type html, text, and css &#160;&#160; &#160;AddOutputFilterByType DEFLATE text/html text/plain text/xml [...]]]></description>
			<content:encoded><![CDATA[<p>在Apache2.x中使用mod_deflate进行gzip压缩，配置信息如下：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">LoadModule deflate_module modules/mod_deflate.so</li>
<li>LoadModule headers_module modules/mod_headers.so</li>
<li>&nbsp;</li>
<li># gzip 设置</li>
<li># Only compress specified content type</li>
<li># see also http://www.devside.net/guides/config/compression</li>
<li>&lt;IfModule mod_deflate.c&gt;</li>
<li>&nbsp;&nbsp; &nbsp;# The value must between 1 (less compression) and 9 (more compression)</li>
<li>&nbsp;&nbsp; &nbsp;DeflateCompressionLevel 7</li>
<li>&nbsp;&nbsp; &nbsp;# compress content with type html, text, and css</li>
<li>&nbsp;&nbsp; &nbsp;AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-httpd-php application/json</li>
<li>&nbsp;&nbsp; &nbsp;# place filter 'DEFLATE' on all outgoing content</li>
<li>&nbsp;&nbsp; &nbsp;SetOutputFilter DEFLATE</li>
<li>&nbsp;&nbsp; &nbsp;# Properly handle old browsers that do not support compression</li>
<li>&nbsp;&nbsp; &nbsp;BrowserMatch ^Mozilla/4 gzip-only-text/html</li>
<li>&nbsp;&nbsp; &nbsp;BrowserMatch ^Mozilla/4\.0[678] no-gzip</li>
<li>&nbsp;&nbsp; &nbsp;BrowserMatch \bMSIE !no-gzip !gzip-only-text/html</li>
<li>&lt;/IfModule&gt;</li></ol></div>
<p>参考资料：<br />
<a href="http://jackyrong.javaeye.com/blog/797656" target="_blank">apache 2.2.15中配置mod_deflate</a><br />
<a href="http://www.devside.net/guides/config/compression" target="_blank">httpd.conf &#8212; compression</a></p>
<div id="crp_related"><h2>Related Posts:</h2><ul><li><a href="http://www.javatang.com/archives/2007/03/10/3018122.html" rel="bookmark" class="crp_title">使Apache实现gzip压缩</a></li><li><a href="http://www.javatang.com/archives/2008/04/20/5034268.html" rel="bookmark" class="crp_title">Javascript的国际化方案</a></li><li><a href="http://www.javatang.com/archives/2007/11/11/5611239.html" rel="bookmark" class="crp_title">两个PHP的Warning及解决方法</a></li><li><a href="http://www.javatang.com/archives/2007/10/06/5104204.html" rel="bookmark" class="crp_title">Javascript怎样设置文本框的readonly属性？</a></li><li><a href="http://www.javatang.com/archives/2010/03/21/1529393.html" rel="bookmark" class="crp_title">ExtJS hack: Add multiple toolbars to a Panel</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.javatang.com/archives/2010/12/01/2805477.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache和Resin组合时间歇性出现503错误的解决方法</title>
		<link>http://www.javatang.com/archives/2010/11/13/1228487.html</link>
		<comments>http://www.javatang.com/archives/2010/11/13/1228487.html#comments</comments>
		<pubDate>Sat, 13 Nov 2010 09:12:28 +0000</pubDate>
		<dc:creator>Jet</dc:creator>
				<category><![CDATA[JavaPlateform]]></category>
		<category><![CDATA[Web&Server]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[resin]]></category>

		<guid isPermaLink="false">http://www.javatang.com/?p=487</guid>
		<description><![CDATA[使用Apache和Resin进行组合时，如果Resin关闭或中断的时会出现如下的HTTP 503错误： Service Temporarily Unavailable The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later. 造成这个错误的原因是因为Resin无法启动，可以单独访问resin（如8080端口）查看具体的错误。 我这里要说的是，在Resin和Apache都非常非常正常的情况下，间歇性的出现上述错误，也就是说不是一直有，而是偶尔出现这个错误，刷新下页面就好了。这个问题非常郁闷，后来在resin的bug报告中（见参考资料）竟然发现了解决的办法： The important configuration are load-balance-socket-timeout, socket-timeout, load-balance-idle-time and keepalive-timeout. The two load-balance-* configure mod_caucho. socket-timeout and keepalive-timeout configure the Resin side. load-balance-socket-timeout needs to be large enough to [...]]]></description>
			<content:encoded><![CDATA[<p>使用Apache和Resin进行组合时，如果Resin关闭或中断的时会出现如下的HTTP 503错误：</p>
<blockquote><p>
Service Temporarily Unavailable<br />
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
</p></blockquote>
<p>造成这个错误的原因是因为Resin无法启动，可以单独访问resin（如8080端口）查看具体的错误。</p>
<p>我这里要说的是，在Resin和Apache都非常非常正常的情况下，<strong>间歇性</strong>的出现上述错误，也就是说不是一直有，而是偶尔出现这个错误，刷新下页面就好了。这个问题非常郁闷，后来在resin的bug报告中（见参考资料）竟然发现了解决的办法：</p>
<blockquote><p>
The important configuration are load-balance-socket-timeout, socket-timeout, load-balance-idle-time and keepalive-timeout. The two load-balance-* configure mod_caucho. socket-timeout and keepalive-timeout configure the Resin side.</p>
<p>load-balance-socket-timeout needs to be large enough to handle any server-side processing delays before the first data.</p>
<p>socket-timeout and keepalive-timeout need to be larger than load-balance-idle-time because they need to keep the connection open for a keepalive request. </p>
<p>For a diagram, see</p>
<p>http://caucho.com/resin/admin/load-balancing.xtp</p>
</blockquote>
<p>也就是说，Resin在同Apache进行组合通讯的时候主要依靠四个参数：load-balance-socket-timeout, socket-timeout, load-balance-idle-time 和 keepalive-timeout，其中两个load-balance-*参数用来设置mod_caucho（就是与Apache组合的so文件），socket-timeout和keepalive-timeout用来设置Resin。至于参数数值的大小顺序依此是：load-balance-socket-timeout &gt; socket-timeout 和 keepalive-timeout &gt; load-balance-idle-time。上述四个参数的官方说明地址为：<a href="http://caucho.com/resin-3.1/doc/server-tags.xtp" target="_blank">http://caucho.com/resin-3.1/doc/server-tags.xtp</a></p>
<p>那为什么会间歇性出现503错误呢？这个是因为resin默认的socket-timeout为65s，时间太短了，有些比较大的请求在这个时间之内还没有进行完。综合上面所说，参考的配置如下：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Olive;">&lt;</span><span style="color: Green;">resin</span><span style="color: Gray;"> ...</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">cluster</span><span style="color: Gray;">&nbsp;</span><span style="color: #00008b;">id</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">app-tier</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">server-default</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">socket-timeout</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">180s</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">socket-timeout</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">keepalive-max</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">3000</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">keepalive-max</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">keepalive-timeout</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">180s</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">keepalive-timeout</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">load-balance-idle-time</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">120s</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">load-balance-idle-time</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">&lt;/</span><span style="color: Green;">server-default</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">&lt;/</span><span style="color: Green;">cluster</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Olive;">&lt;/</span><span style="color: Green;">resin</span><span style="color: Olive;">&gt;</span></li></ol></div>
<p>从此，这个世界清净了。</p>
<p>参考资料：<br />
<a href="http://bugs.caucho.com/view.php?id=2715" target="_blank">Apache 2.2.x + Resin 3.1.x: frequent 503 status error messages (Service Temporarily Unavailable)</a><br />
<a href="http://bugs.caucho.com/view.php?id=2862" target="_blank">0002862: Apache + Resin and 503 HTTP Error</a><br />
<a href="http://aiter.javaeye.com/blog/391456" target="_blank">resin apache问题</a></p>
<div id="crp_related"><h2>Related Posts:</h2><ul><li><a href="http://www.javatang.com/archives/2011/10/18/1847563.html" rel="bookmark" class="crp_title">Ext中设置Ajax超时时间</a></li><li><a href="http://www.javatang.com/archives/2007/07/04/1548182.html" rel="bookmark" class="crp_title">PHP中出现“Unable to load dynamic library”问题的解决方法</a></li><li><a href="http://www.javatang.com/archives/2010/11/14/1752494.html" rel="bookmark" class="crp_title">Resin中对日志输出的配置</a></li><li><a href="http://www.javatang.com/archives/2008/10/18/1942276.html" rel="bookmark" class="crp_title">Apache+Resin下如何写伪静态和301跳转</a></li><li><a href="http://www.javatang.com/archives/2007/11/02/0146237.html" rel="bookmark" class="crp_title">“终端服务超出最大允许连接数”问题产生原因及解决方法</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.javatang.com/archives/2010/11/13/1228487.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache和Resin组合时UrlRewriteFilter失效的解决方法</title>
		<link>http://www.javatang.com/archives/2010/08/27/3629451.html</link>
		<comments>http://www.javatang.com/archives/2010/08/27/3629451.html#comments</comments>
		<pubDate>Fri, 27 Aug 2010 09:36:29 +0000</pubDate>
		<dc:creator>Jet</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[Web&Server]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[resin]]></category>

		<guid isPermaLink="false">http://www.javatang.com/?p=451</guid>
		<description><![CDATA[目前在Spring3.0的官方example中都使用UrlRewriteFilter来做伪静态，单独运行在Resin等JavaEE Web容器中的时候一切都OK，但是一旦与Apache一起组合的时候总是会出现404或403错误，当然UrlRewriteFilter所设定的规则也无效。 造成这种现象的原因是因为在默认情况下，静态的资源均由Apache进行处理，而jsp或者由web.xml所映射的servlet均交给resin进行处理。如果web项目没有使用UrlRewriteFilter则一切OK，但是使用了UrlRewriteFilter之后，由servlet所映射的地址并不是/*即所有资源了，而是类似/app/*这样的设置。也就是说，用户所请求的资源首先由Apache判断一下，然后再由选择的交给Resin，最后才执行UrlRewriteFilter的规则。 知道了原因，解决的方法也就出来了，只要告诉Apache将所有的资源都交由Resin来处理就可以了，可以使用Resin的servlet-mapping方法进行配置，配置如下： &#60;servlet-mapping url-pattern='/*' servlet-name='plugin_match'/&#62; 其中plugin_match是Resin内置的servlet，按照resin官方的解释就是Resin告诉Apache将所有的符合url-pattern规则要求的请求都发送给它进行处理。 因为servlet-mapping是resin特有的，所以建议将此也放在resin-web.xml中，然后放在项目中的WEB-INF目录下： &#60;web-app xmlns=&#34;http://caucho.com/ns/resin&#34; &#160; &#160; &#160; &#160;&#160; xmlns:resin=&#34;http://caucho.com/ns/resin/core&#34;&#62; &#160; &#160; &#60;servlet-mapping&#160;url-pattern='/*' servlet-name='plugin_match'/&#62; &#60;/web-app&#62; 参考资料： Apache的UrlRewrite和Resin的配置问题 Resin官方对servlet-mapping的说明 Related Posts:Resin 3.0.x 经验总结DWR文档之开始使用 DWR如何使用DWR2.0的注解功能Apache+Resin下如何写伪静态和301跳转Resin中对日志输出的配置]]></description>
			<content:encoded><![CDATA[<p>目前在Spring3.0的官方example中都使用UrlRewriteFilter来做伪静态，单独运行在Resin等JavaEE Web容器中的时候一切都OK，但是一旦与Apache一起组合的时候总是会出现404或403错误，当然UrlRewriteFilter所设定的规则也无效。</p>
<p>造成这种现象的原因是因为在默认情况下，静态的资源均由Apache进行处理，而jsp或者由web.xml所映射的servlet均交给resin进行处理。如果web项目没有使用UrlRewriteFilter则一切OK，但是使用了UrlRewriteFilter之后，由servlet所映射的地址并不是/*即所有资源了，而是类似/app/*这样的设置。也就是说，用户所请求的资源首先由Apache判断一下，然后再由选择的交给Resin，最后才执行UrlRewriteFilter的规则。</p>
<p>知道了原因，解决的方法也就出来了，只要告诉Apache将所有的资源都交由Resin来处理就可以了，可以使用Resin的servlet-mapping方法进行配置，配置如下：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Olive;">&lt;</span><span style="color: Green;">servlet-mapping</span><span style="color: Gray;"> </span><span style="color: #00008b;">url-pattern</span><span style="color: Gray;">='/*' </span><span style="color: #00008b;">servlet-name</span><span style="color: Gray;">='</span><span style="color: #00008b;">plugin_match</span><span style="color: Gray;">'</span><span style="color: Olive;">/&gt;</span></li></ol></div>
<p>其中plugin_match是Resin内置的servlet，按照resin官方的解释就是Resin告诉Apache将所有的符合url-pattern规则要求的请求都发送给它进行处理。</p>
<p>因为servlet-mapping是resin特有的，所以建议将此也放在resin-web.xml中，然后放在项目中的WEB-INF目录下：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Olive;">&lt;</span><span style="color: Green;">web-app</span><span style="color: Gray;"> </span><span style="color: #00008b;">xmlns</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">http://caucho.com/ns/resin</span><span style="color: #8b0000;">&quot;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; </span><span style="color: #00008b;">xmlns:resin</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">http://caucho.com/ns/resin/core</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">servlet-mapping</span><span style="color: Gray;">&nbsp;</span><span style="color: #00008b;">url-pattern</span><span style="color: Gray;">='/*' </span><span style="color: #00008b;">servlet-name</span><span style="color: Gray;">='</span><span style="color: #00008b;">plugin_match</span><span style="color: Gray;">'</span><span style="color: Olive;">/&gt;</span></li>
<li><span style="color: Olive;">&lt;/</span><span style="color: Green;">web-app</span><span style="color: Olive;">&gt;</span></li></ol></div>
<p>参考资料：<br />
<a href="http://highbird.blog.sohu.com/70318160.html" target="_blank">Apache的UrlRewrite和Resin的配置问题</a><br />
<a href="http://www.caucho.com/resin-3.0/config/webapp.xtp#servlet-mapping" target="_blank">Resin官方对servlet-mapping的说明</a></p>
<div id="crp_related"><h2>Related Posts:</h2><ul><li><a href="http://www.javatang.com/archives/2006/08/21/010658.html" rel="bookmark" class="crp_title">Resin 3.0.x 经验总结</a></li><li><a href="http://www.javatang.com/archives/2006/10/20/254879.html" rel="bookmark" class="crp_title">DWR文档之开始使用 DWR</a></li><li><a href="http://www.javatang.com/archives/2008/07/07/5648271.html" rel="bookmark" class="crp_title">如何使用DWR2.0的注解功能</a></li><li><a href="http://www.javatang.com/archives/2008/10/18/1942276.html" rel="bookmark" class="crp_title">Apache+Resin下如何写伪静态和301跳转</a></li><li><a href="http://www.javatang.com/archives/2010/11/14/1752494.html" rel="bookmark" class="crp_title">Resin中对日志输出的配置</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.javatang.com/archives/2010/08/27/3629451.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache下FastCGI模块的众多版本</title>
		<link>http://www.javatang.com/archives/2010/01/07/3629356.html</link>
		<comments>http://www.javatang.com/archives/2010/01/07/3629356.html#comments</comments>
		<pubDate>Thu, 07 Jan 2010 08:36:29 +0000</pubDate>
		<dc:creator>Jet</dc:creator>
				<category><![CDATA[OS]]></category>
		<category><![CDATA[Web&Server]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[fastcgi]]></category>

		<guid isPermaLink="false">http://www.javatang.com/?p=356</guid>
		<description><![CDATA[这两天在Apache上配置以FastCGI方式来加载PHP和Perl，连续花了三天的时间才正式配置好并且稳定了，配置的话到不是很麻烦，关键是配置好之后还要稳定。后续我会将整个过程记录下来给大家分享，今天我要先说的是FastCGI的版本问题。 目前我们在网上能够找到的FastCGI有三个版本： (1) mod_fastcgi：官方地址是http://www.fastcgi.com/。这个可以说是最初始的FastCGI的版本，可惜的是现在作者已经好久没有维护了，现存编译好的版本非常少，其官方网站更多的是以一个“标准”的姿态出现的。现在给出通过官方网站没法直接找到的两个地址，一个是下载地址http://www.fastcgi.com/dist/，另外一个是相关的配置参数的文档http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html。虽然是官方标准，但是不建议在生产环境中直接使用，因为它特别的不稳定，而且兼容性极差。 (2) mod_fcgid v2.2：官方地址是http://fastcgi.coremail.cn/，不过网站现在打不开了，所幸的是可以在http://www.apachelounge.com/download/网站上下载。fcgid是在fastcgi的基础上进行了扩展和优化，并且针对Apache的新版本做了及时的更新，使得可以在生产环境下使用，二者具体的区别可以阅读下面的参考资料。原来在coremail上所提供的文件因为现在网站没法访问，所以具体的关于ApacheLounge上所提供的mod_fcgid2.2和coremail上所提供的有什么区别我不是很了解。所幸我找到了作者的邮箱，通过跟作者邮件沟通了解到，原来作者在做完第一个版本的fcgid之后就将源代码发布到了网上，后来ApacheLounge的Steffen使用源代码重新在Windows下面编译后发布了可以直接使用的二进制版本的mod_fcgid.so文件。同时，Steffen也是Apache Windows版本的一个维护者。经过试用，我感觉这个版本的mod_fcgid是最适合在Windows环境下使用的。 (3) mod_fcgid v2.3.x +：官方地址为http://httpd.apache.org/mod_fcgid/，相关文档地址为：http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html。这个是目前Apache官方所提供的mod_fcgid，目前最新版本为2.3.4。通过作者了解到，这个是作者将原来放在coremail上的mod_fcgid代码捐献给Apache之后由Apache官方来维护的一个版本，可以说是2.2版本之后的后续版本。但是我在Windows上面使用之后感觉不是很稳定，Apache总是隔一段时间就自动关闭，不知道是我设置的问题还是其他问题。 综合来看，上面三个版本的情况如下： mod_fastcgi：最初始的标准版本，适合开发，不适合直接在生产环境中使用； mod_fcgid v2.2：目前在Apache Lounge上提供下载，个人认为是最适合在Windows环境下使用的一个版本，缺点是因为原来的fastcgi.coremail.cn网站已经不能访问，所以所参考的文档极少； mod_fcgid v2.3.x +：最新最稳定的官方版本，其特点是目前mod_fcgid中最新的版本，而且是有官方来维护，文档内容也非常丰富。但以我个人使用来看，在Windows环境下不是很稳定。 更新(2010.1.8)：经过同mod_fcgid原作者Ryan Pan (Pan Qingfeng, pqf or 潘庆峰)沟通，他已经答应将原来在http://fastcgi.coremail.cn/的内容放到本站做镜像，详细说明见http://www.javatang.com/mod_fcgid-v2-2-mirror 附同mod_fcgid作者沟通的邮件内容(经本人允许)： 庆峰，你好！ 很冒昧的给你发mail，我是mod_fcgid的使用者，有个疑问一直未知，就是关于mod_fcgid版本的问题。我现在在网络上找到三种mod_fcgid的版本： (1) 在http://www.apachelounge.com/download/上列出的两个mod_fcgid-2.2b-w32.zip(用于Apache 2.2.9+)和 mod_fcgid-2.2a-w32.zip(用于Apache 2.2.0到2.2.8)，作者好像是Steffen。 (2) 在http://fastcgi.coremail.cn/index.cn.htm(现在无法访问了)上也有一个mod_fcgid，作者的信息我只在ChinaUnix找到一个帖子http://bbs3.chinaunix.net/thread-320106-1-1.html，有人说跟上面的是同一个，但因为网站无法访问，所以没有办法看到。 (3) 最后一个就是你写的mod_fcgid了，官方地址是http://httpd.apache.org/mod_fcgid/，现在的版本是2.3.4，详细文档地址是http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html。 因为想在实际的项目中使用mod_fcgid加载PHP，所以还望解答我的疑问，非常感谢！ 顺颂商祺！ 马志勇 (Jet Ma) ========================= Hi, 马先生 （1）其实是专门维护Windows版Apache的一位外国朋友做的，源代码也是来自标准的mod_fcgid, 不过Steffen维护的是Windows版的编译好的mod_fcgid.so，方便大家直接使用（Windows很多人没有安装编译工具，直接给源代码大家基本上没多少人可以用的上) (2) 之前做mod_fcgid的时候，代码和文档一直放在这里的，但是后来代码捐献了给Apache之后，这里就不再维护了，另外最近公司服务器做了一些调整，我也改不了redirect到apache网站了 (3) 这是当前官方的mod_fcgid, 维护的是最新最稳定的mod_fcgid, Apache软件基金会的程序员（我也是其中之一）正在维护这个项目，如果您有什么问题，可以直接在Apache的邮件列表提出的（不过使用问题最好不要在开发邮件列表提出了) [...]]]></description>
			<content:encoded><![CDATA[<p>这两天在Apache上配置以FastCGI方式来加载PHP和Perl，连续花了三天的时间才正式配置好并且稳定了，配置的话到不是很麻烦，关键是配置好之后还要稳定。后续我会将整个过程记录下来给大家分享，今天我要先说的是FastCGI的版本问题。</p>
<p>目前我们在网上能够找到的FastCGI有三个版本：<br />
(1) <strong>mod_fastcgi</strong>：官方地址是<a href="http://www.fastcgi.com/" target="_blank">http://www.fastcgi.com/</a>。这个可以说是最初始的FastCGI的版本，可惜的是现在作者已经好久没有维护了，现存编译好的版本非常少，其官方网站更多的是以一个“标准”的姿态出现的。现在给出通过官方网站没法直接找到的两个地址，一个是下载地址<a href="http://www.fastcgi.com/dist/" target="_blank">http://www.fastcgi.com/dist/</a>，另外一个是相关的配置参数的文档<a href="http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html" target="_blank">http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html</a>。虽然是官方标准，但是<strong>不建议在生产环境中直接使用</strong>，因为它特别的不稳定，而且兼容性极差。</p>
<p>(2) <strong>mod_fcgid v2.2</strong>：官方地址是<a href="http://fastcgi.coremail.cn/" target="_blank">http://fastcgi.coremail.cn/</a>，不过网站现在打不开了，所幸的是可以在<a href="http://www.apachelounge.com/download/" target="_blank">http://www.apachelounge.com/download/</a>网站上下载。fcgid是在fastcgi的基础上进行了扩展和优化，并且针对Apache的新版本做了及时的更新，使得可以在生产环境下使用，二者具体的区别可以阅读下面的参考资料。原来在coremail上所提供的文件因为现在网站没法访问，所以具体的关于ApacheLounge上所提供的mod_fcgid2.2和coremail上所提供的有什么区别我不是很了解。所幸我找到了作者的邮箱，通过跟作者邮件沟通了解到，原来作者在做完第一个版本的fcgid之后就将源代码发布到了网上，后来ApacheLounge的Steffen使用源代码重新在Windows下面编译后发布了可以直接使用的二进制版本的mod_fcgid.so文件。同时，Steffen也是Apache Windows版本的一个维护者。经过试用，我感觉这个版本的mod_fcgid是最适合在Windows环境下使用的。</p>
<p>(3) <strong>mod_fcgid v2.3.x +</strong>：官方地址为<a href="http://httpd.apache.org/mod_fcgid/" target="_blank">http://httpd.apache.org/mod_fcgid/</a>，相关文档地址为：<a href="http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html" target="_blank">http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html</a>。这个是目前Apache官方所提供的mod_fcgid，目前最新版本为2.3.4。通过作者了解到，这个是作者将原来放在coremail上的mod_fcgid代码捐献给Apache之后由Apache官方来维护的一个版本，可以说是2.2版本之后的后续版本。但是我在Windows上面使用之后感觉不是很稳定，Apache总是隔一段时间就自动关闭，不知道是我设置的问题还是其他问题。</p>
<p>综合来看，上面三个版本的情况如下：</p>
<li>mod_fastcgi：最初始的标准版本，适合开发，不适合直接在生产环境中使用；</li>
<li>mod_fcgid v2.2：目前在Apache Lounge上提供下载，个人认为是最适合在Windows环境下使用的一个版本，缺点是因为原来的fastcgi.coremail.cn网站已经不能访问，所以所参考的文档极少；</li>
<li>mod_fcgid v2.3.x +：最新最稳定的官方版本，其特点是目前mod_fcgid中最新的版本，而且是有官方来维护，文档内容也非常丰富。但以我个人使用来看，在Windows环境下不是很稳定。</li>
<p>更新(2010.1.8)：经过同mod_fcgid原作者Ryan Pan (Pan Qingfeng, pqf or 潘庆峰)沟通，他已经答应将原来在http://fastcgi.coremail.cn/的内容放到本站做镜像，详细说明见<a href="http://www.javatang.com/mod_fcgid-v2-2-mirror" target="_blank">http://www.javatang.com/mod_fcgid-v2-2-mirror</a></p>
<p>附同mod_fcgid作者沟通的邮件内容(经本人允许)：</p>
<blockquote><p>
庆峰，你好！<br />
很冒昧的给你发mail，我是mod_fcgid的使用者，有个疑问一直未知，就是关于mod_fcgid版本的问题。我现在在网络上找到三种mod_fcgid的版本：<br />
(1) 在http://www.apachelounge.com/download/上列出的两个mod_fcgid-2.2b-w32.zip(用于Apache 2.2.9+)和 mod_fcgid-2.2a-w32.zip(用于Apache 2.2.0到2.2.8)，作者好像是Steffen。<br />
(2) 在http://fastcgi.coremail.cn/index.cn.htm(现在无法访问了)上也有一个mod_fcgid，作者的信息我只在ChinaUnix找到一个帖子http://bbs3.chinaunix.net/thread-320106-1-1.html，有人说跟上面的是同一个，但因为网站无法访问，所以没有办法看到。<br />
(3) 最后一个就是你写的mod_fcgid了，官方地址是http://httpd.apache.org/mod_fcgid/，现在的版本是2.3.4，详细文档地址是http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html。<br />
因为想在实际的项目中使用mod_fcgid加载PHP，所以还望解答我的疑问，非常感谢！<br />
顺颂商祺！<br />
马志勇 (Jet Ma)<br />
=========================<br />
Hi, 马先生<br />
    （1）其实是专门维护Windows版Apache的一位外国朋友做的，源代码也是来自标准的mod_fcgid, 不过Steffen维护的是Windows版的编译好的mod_fcgid.so，方便大家直接使用（Windows很多人没有安装编译工具，直接给源代码大家基本上没多少人可以用的上)<br />
   (2) 之前做mod_fcgid的时候，代码和文档一直放在这里的，但是后来代码捐献了给Apache之后，这里就不再维护了，另外最近公司服务器做了一些调整，我也改不了redirect到apache网站了<br />
   (3) 这是当前官方的mod_fcgid, 维护的是最新最稳定的mod_fcgid, Apache软件基金会的程序员（我也是其中之一）正在维护这个项目，如果您有什么问题，可以直接在Apache的邮件列表提出的（不过使用问题最好不要在开发邮件列表提出了)</p>
<p>Thanks
</p></blockquote>
<p>参考资料：<br />
<a href="http://blog.chinaunix.net/u/31839/showart_2057531.html" target="_blank">mod_fastcgi和mod_fcgid的区别</a><br />
<a href="http://purpen.javaeye.com/blog/68318" target="_blank">Windows 下 Apache 1.3 以 FastCGI 模式运行 PHP</a></p>
<div id="crp_related"><h2>Related Posts:</h2><ul><li><a href="http://www.javatang.com/archives/2007/06/20/1513177.html" rel="bookmark" class="crp_title">Apache和Resin产生大容量日志的解决办法</a></li><li><a href="http://www.javatang.com/archives/2008/01/22/0615259.html" rel="bookmark" class="crp_title">解决Apache出现的CPU高占用率的问题</a></li><li><a href="http://www.javatang.com/archives/2006/08/21/010658.html" rel="bookmark" class="crp_title">Resin 3.0.x 经验总结</a></li><li><a href="http://www.javatang.com/archives/2011/09/20/2831546.html" rel="bookmark" class="crp_title">Apache+Resin发布程序时一直出现403错误的解决办法</a></li><li><a href="http://www.javatang.com/archives/2008/10/18/1942276.html" rel="bookmark" class="crp_title">Apache+Resin下如何写伪静态和301跳转</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.javatang.com/archives/2010/01/07/3629356.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Subversion和Apache的安装使用指南</title>
		<link>http://www.javatang.com/archives/2009/12/31/2139330.html</link>
		<comments>http://www.javatang.com/archives/2009/12/31/2139330.html#comments</comments>
		<pubDate>Thu, 31 Dec 2009 05:21:39 +0000</pubDate>
		<dc:creator>Jet</dc:creator>
				<category><![CDATA[JavaPlateform]]></category>
		<category><![CDATA[Web&Server]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[subversion]]></category>

		<guid isPermaLink="false">http://www.javatang.com/?p=330</guid>
		<description><![CDATA[虽然Subversion(SVN)直接可以注册为服务程序，但是最方便的还是使用SVN+Apache的方式，因为可以无防火墙限制、方便直接使用浏览器对代码进行浏览等等。下面我就将自己在Windows下安装Subversion(SVN)和Apache的方法记录一下： 1. 从Apache网站上下载Apache的安装包进行安装，这个过程比较简单。需要注意Apache的版本，本文采用2.2，当然也可以使用2.0版本。假定Apache的安装目录为D:\apache2。 2. 在http://subversion.tigris.org/官方下载Subversion的Windows下面与Apache的配合版本，这里需要注意Apache的版本，2.0和2.2的是不一样的，不要下载错了。 然后将下载下来的zip包解压缩到一个目录，比如D:\svn-win32-1.6.6。 3. 将svn安装目录的bin目录下面的mod_authz_svn.so和mod_dav_svn.so两个文件拷贝到Apache安装目录的modules目录下面，然后修改Apache的配置文件httpd.conf，将下面两行的注释去掉： LoadModule dav_fs_module modules/mod_dav_fs.so LoadModule dav_module modules/mod_dav.so 同时在下面增加两行： LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule authz_svn_module modules/mod_authz_svn.so 4. 接下来就是对SVN进行配置了，配置文件(包含每条的含义)如下： # 表示访问SVN的地址，形式为http:///svn &#60;Location /svn&#62; # 告诉Apache哪个模块负责服务像那样的URL－－在这里就是Subversion模块 DAV svn # 在Subversion 1.3及更高版本中，这个指示器使得Subversion列出由SVNParentPath指定的目录下所有的版本库 SVNListParentPath on # 下面制定SVN仓库的位置，有两种选择： # (1) 单库：一个Apache下面只有一个SVN仓库，这样的话就使用SVNPath来指定唯一的仓库位置，访问仓库的方式是http:///svn # (2) 多库：一个Apache下面可以有多个SVN仓库，这样的话就使用SVNParentPath来指定所有仓库所在的主目录，访问仓库的方式是http:///svn/仓库1、http:///svn/仓库2等等 SVNPath “D:\Data\SVNData\repository” #SVNParentPath “D:\Data\SVNData\repository” # 当一个验证对话框弹出时，告诉用户这个验证是用来做什么的 AuthName “Subversion repositories” # 启用基本的验证，比如用户名/密码对，通常来做这样做就已经足够了。 [...]]]></description>
			<content:encoded><![CDATA[<p>虽然Subversion(SVN)直接可以注册为服务程序，但是最方便的还是使用SVN+Apache的方式，因为可以无防火墙限制、方便直接使用浏览器对代码进行浏览等等。下面我就将自己在Windows下安装Subversion(SVN)和Apache的方法记录一下：</p>
<p>1. 从Apache网站上下载Apache的安装包进行安装，这个过程比较简单。需要注意Apache的版本，本文采用2.2，当然也可以使用2.0版本。假定Apache的安装目录为D:\apache2。</p>
<p>2. 在<a href="http://subversion.tigris.org/getting.html#windows" target="_blank">http://subversion.tigris.org/</a>官方下载Subversion的Windows下面与Apache的配合版本，这里需要注意Apache的版本，2.0和2.2的是不一样的，不要下载错了。<br />
<img src="http://www.javatang.com/wp-content/Tigris.org_svn.png" alt="" title="Tigris.org_svn"  class="alignnone size-medium wp-image-332" /><br />
然后将下载下来的zip包解压缩到一个目录，比如D:\svn-win32-1.6.6。</p>
<p>3. 将svn安装目录的bin目录下面的mod_authz_svn.so和mod_dav_svn.so两个文件拷贝到Apache安装目录的modules目录下面，然后修改Apache的配置文件httpd.conf，将下面两行的注释去掉：</p>
<blockquote><p>
LoadModule dav_fs_module modules/mod_dav_fs.so<br />
LoadModule dav_module modules/mod_dav.so
</p></blockquote>
<p>同时在下面增加两行：</p>
<blockquote><p>
LoadModule dav_svn_module modules/mod_dav_svn.so<br />
LoadModule authz_svn_module modules/mod_authz_svn.so
</p></blockquote>
<p>4. 接下来就是对SVN进行配置了，配置文件(包含每条的含义)如下：</p>
<blockquote><p>
# 表示访问SVN的地址，形式为http://<your_domain>/svn<br />
&lt;Location /svn&gt;<br />
    # 告诉Apache哪个模块负责服务像那样的URL－－在这里就是Subversion模块<br />
    DAV svn<br />
    # 在Subversion 1.3及更高版本中，这个指示器使得Subversion列出由SVNParentPath指定的目录下所有的版本库<br />
    SVNListParentPath on<br />
    # 下面制定SVN仓库的位置，有两种选择：<br />
   # (1) 单库：一个Apache下面只有一个SVN仓库，这样的话就使用SVNPath来指定唯一的仓库位置，访问仓库的方式是http://<your_domain>/svn<br />
   # (2) 多库：一个Apache下面可以有多个SVN仓库，这样的话就使用SVNParentPath来指定所有仓库所在的主目录，访问仓库的方式是http://<your_domain>/svn/仓库1、http://<your_domain>/svn/仓库2等等<br />
    SVNPath “D:\Data\SVNData\repository”<br />
    #SVNParentPath “D:\Data\SVNData\repository”</p>
<p>    # 当一个验证对话框弹出时，告诉用户这个验证是用来做什么的<br />
    AuthName “Subversion repositories”<br />
    # 启用基本的验证，比如用户名/密码对，通常来做这样做就已经足够了。<br />
    AuthType Basic<br />
    # 指定密码文件的位置，密码文件中存放了用来验证用户的用户名和密码信息。这个文件的生成方式在后续步骤中会介绍<br />
    AuthUserFile “D:\Data\SVNData\config\passwd”<br />
    # 对版本库和人员进行权限分配，后面会进行详细的设置和介绍。<br />
    AuthzSVNAccessFile “D:\Data\SVNData\config\svnaccessfile”</p>
<p>    # 限定用户只有输入正确的用户名及密码后才能访问这个路径<br />
    Require valid-user<br />
    # 如果想匿名读取的话使用下面的方式<br />
    #&lt;LimitExcept GET PROPFIND OPTIONS REPORT&gt;<br />
    #Require valid-user<br />
    #&lt;/LimitExcept&gt;<br />
&lt;/Location&gt;
</p></blockquote>
<p>5. 接下来使用Apache中的htpasswd.exe命令来生成密码文件，也就是上面AuthUserFile 设置项所指向的文件，切换到Apache安装目录的bin目录下，指向下面的命令：</p>
<blockquote><p>
# 后面的参数c表示新建文件，在第一次执行的时候使用<br />
htpasswd -c D:\Data\SVNData\config\passwd &lt;username&gt;<br />
# 如果是追加新用户或修改原有用户密码，命令后面不加参数c<br />
htpasswd D:\Data\SVNData\config\passwd &lt;username&gt;
</p></blockquote>
<p>每次执行命令之后会提示输入两遍密码</p>
<p>6. 这个时候如果重启Apache的话会出现一个错误提示，这个是因为svn所使用的一些dll文件apache还无法获取，解决的方法可以将svn安装目录的bin目录下面的dll文件拷贝到系统的system32目录下面，但最好的方式是将bin目录加入到path环境变量中。</p>
<p>7. 这个时候如果访问http://<your_domain>/svn的话，应该会出现一个登录框，输入用户名/密码之后就可以看到SVN仓库的内容了。不过常见下面的几个错误：<br />
(1) 出现“403 Forbidden”错误<br />
出现这个错误的原因有很多种，比如Apache2.2相对于之前的版本来说增强了安全性，默认情况下目录是禁止访问的，将“&lt;Directory /&gt;”修改如下：</p>
<blockquote><p>
&lt;Directory /&gt;<br />
    Options FollowSymLinks<br />
    AllowOverride None<br />
    Order deny,allow<br />
    Allow from all<br />
&lt;/Directory&gt;
</p></blockquote>
<p>如果这样还不行的话那就是“多库还是单库”的问题了。上面讲过，在对SVN进行配置的时候，使用SVNParentPath设置所有库的根目录，在根目录下面存放多个SVN的库，那这样的话直接访问父目录是没有权限的，只能通过http://<your_domain>/svn/project1来访问对应的项目仓库；如果使用SVNPath设置为单库的话则不会出现这个错误了。</p>
<p>(2) 出现“&lt;m:human-readable errcode=”720003&#8243;&gt;Could not open the requested SVN filesystem&lt;/m:human-readable&gt;”错误<br />
出现这个错误是告诉你你所指定的SVN仓库的位置并不是一个合法的SVN仓库，解决的方法是首先创建一个空目录，然后使用“svnadmin create”命令来创建SVN库：</p>
<blockquote><p>
# 首先进入 D:\Data\SVNData\repository 目录下<br />
md project1<br />
svnadmin create D:\Data\SVNData\repository\project1
</p></blockquote>
<p>8. 最后安装SVN客户端就可以访问啦，Eclipse集成的客户端推荐使用<a href="http://subclipse.tigris.org/" target="_blank">Subclipse</a>，Visual Studio集成的客户端推荐使用<a href="http://ankhsvn.open.collab.net/" target="_blank">ankhsvn</a>，系统集成的客户端推荐使用<a href="http://tortoisesvn.tigris.org/" target="_blank">TortoiseSVN</a>。</p>
<p>参考资料：<br />
<a href="http://bbs.iusesvn.com/thread-158-1-1.html" target="_blank">[翻译] windows安装基于Apache的SVN服务器(包括SSL配置)</a><br />
<a href="http://www.iusesvn.com/bbs/thread-157-1-1.html" target="_blank">基于svnserve的服务器，权限文件authz配置的常见问题及解答</a><br />
<a href="http://www.svnforum.org/2017/viewtopic.php?p=876" target="_blank">Forbidden access or bad repository ?</a><br />
<a href="http://alexclark.itpub.net/post/670/5647" target="_blank">Subversion for Windows 安裝指南</a> </p>
<div id="crp_related"><h2>Related Posts:</h2><ul><li><a href="http://www.javatang.com/archives/2007/03/30/1025157.html" rel="bookmark" class="crp_title">Windows下安装zip包版本的MySQL</a></li><li><a href="http://www.javatang.com/archives/2010/07/11/4201420.html" rel="bookmark" class="crp_title">彻底修改Google Chrome浏览器的安装目录</a></li><li><a href="http://www.javatang.com/archives/2008/02/19/0801260.html" rel="bookmark" class="crp_title">Windows NT系统下的Apache性能优化</a></li><li><a href="http://www.javatang.com/archives/2010/12/01/2805477.html" rel="bookmark" class="crp_title">Apache2.x中设置gzip</a></li><li><a href="http://www.javatang.com/archives/2010/11/23/5817513.html" rel="bookmark" class="crp_title">Spring MVC中修改校验的异常信息</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.javatang.com/archives/2009/12/31/2139330.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache+Resin下如何写伪静态和301跳转</title>
		<link>http://www.javatang.com/archives/2008/10/18/1942276.html</link>
		<comments>http://www.javatang.com/archives/2008/10/18/1942276.html#comments</comments>
		<pubDate>Sat, 18 Oct 2008 19:19:42 +0000</pubDate>
		<dc:creator>Jet</dc:creator>
				<category><![CDATA[SearchEngine]]></category>
		<category><![CDATA[Web&Server]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[resin]]></category>
		<category><![CDATA[seo]]></category>

		<guid isPermaLink="false">http://www.javatang.com/archives/2008/10/18/1942276.html</guid>
		<description><![CDATA[目前网上大多数资料都是介绍如何在Apache中设置伪静态的，在Resin中很少提及，经过实践实现了这一点，现在做如下总结。 1. Apache下如何写伪静态和301重定向 直接上代码（以本站域名为例）： &#60;IfModule mod_rewrite.c&#62; &#160;&#160; &#160;RewriteEngine On &#160;&#160; &#160;# 叹号表示非，L表示最终结果，不再循环；NC是不区分大小写。 &#160;&#160; &#160;RewriteCond %{http_host} !^www.javatang.com [NC] &#160;&#160; &#160;RewriteRule ^/(.*)$ http://www.javatang.com/$1 [R=301,NC,L] &#160;&#160; &#160;RewriteRule ^(.*)/index(.*)$ $1/index.html [R=301,NC] &#160; &#60;/IfModule&#62; 2. Resin下如何写伪静态和301重定向 Resin下的重定向也是由伪静态来写的，不过具体一些的话他同页面伪静态是分别由两个tag来完成的，页面伪静态由forward完成，301永久重定向由moved-permanently完成。 下面是具体的代码： &#60;rewrite-dispatch&#62; &#160; &#160; &#160; &#160; &#60;forward&#160;regexp=&#34;^(.*)/archives/([^/]+)/([^/]+).html$&#34; target=&#34;$1/archives.jsp?q=$3&#38;amp;a=$2&#34; /&#62; &#160; &#160; &#160; &#160; &#60;!-- HTTP 301 moved --&#62; &#160; &#160; &#160; &#160; &#60;moved-permanently&#160;regexp=&#34;^(.*)/index(.*)$&#34; [...]]]></description>
			<content:encoded><![CDATA[<p>目前网上大多数资料都是介绍如何在Apache中设置伪静态的，在Resin中很少提及，经过实践实现了这一点，现在做如下总结。</p>
<p><strong>1. Apache下如何写伪静态和301重定向</strong><br />
直接上代码（以本站域名为例）：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">&lt;IfModule mod_rewrite.c&gt;</li>
<li>&nbsp;&nbsp; &nbsp;RewriteEngine On</li>
<li>&nbsp;&nbsp; &nbsp;# 叹号表示非，L表示最终结果，不再循环；NC是不区分大小写。</li>
<li>&nbsp;&nbsp; &nbsp;RewriteCond %{http_host} !^www.javatang.com [NC]</li>
<li>&nbsp;&nbsp; &nbsp;RewriteRule ^/(.*)$ http://www.javatang.com/$1 [R=301,NC,L]</li>
<li>&nbsp;&nbsp; &nbsp;RewriteRule ^(.*)/index(.*)$ $1/index.html [R=301,NC]</li>
<li>&nbsp; &lt;/IfModule&gt;</li></ol></div>
<p><strong>2. Resin下如何写伪静态和301重定向</strong><br />
Resin下的重定向也是由伪静态来写的，不过具体一些的话他同页面伪静态是分别由两个tag来完成的，页面伪静态由forward完成，301永久重定向由moved-permanently完成。</p>
<p>下面是具体的代码：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Olive;">&lt;</span><span style="color: Green;">rewrite-dispatch</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">forward</span><span style="color: Gray;">&nbsp;</span><span style="color: #00008b;">regexp</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">^(.*)/archives/([^/]+)/([^/]+).html$</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">target</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">$1/archives.jsp?q=$3</span><span style="color: Navy;">&amp;amp;</span><span style="color: Red;">a=$2</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Olive;">/&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #ffa500;">&lt;!-- HTTP 301 moved --&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">moved-permanently</span><span style="color: Gray;">&nbsp;</span><span style="color: #00008b;">regexp</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">^(.*)/index(.*)$</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">target</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">$1/index.html</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">/&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">&lt;/</span><span style="color: Green;">rewrite-dispatch</span><span style="color: Olive;">&gt;</span></li></ol></div>
<p>这里需要特别注意的一点就是地址中的QueryString中&#038;连接符需要使用&amp;来代替，否则为出现错误。</p>
<p>因为JavaEE默认的web.xml文件不支持上述属性，所以可以在你的站点WEB-INF目录下创建一个resin-web.xml文件，这个文件会被Resin看作为站点配置文件，然后在文件中写下如下内容：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Olive;">&lt;</span><span style="color: Green;">web-app</span><span style="color: Gray;"> </span><span style="color: #00008b;">xmlns</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">http://caucho.com/ns/resin</span><span style="color: #8b0000;">&quot;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; </span><span style="color: #00008b;">xmlns:resin</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">http://caucho.com/ns/resin/core</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">rewrite-dispatch</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">forward</span><span style="color: Gray;">&nbsp;</span><span style="color: #00008b;">regexp</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">^(.*)/archives/([^/]+)/([^/]+).html$</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">target</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">$1/archives.jsp?q=$3</span><span style="color: Navy;">&amp;amp;</span><span style="color: Red;">a=$2</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Olive;">/&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #ffa500;">&lt;!-- HTTP 301 moved --&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">moved-permanently</span><span style="color: Gray;">&nbsp;</span><span style="color: #00008b;">regexp</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">^(.*)/index(.*)$</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">target</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">$1/index.html</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">/&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">&lt;/</span><span style="color: Green;">rewrite-dispatch</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Olive;">&lt;/</span><span style="color: Green;">web-app</span><span style="color: Olive;">&gt;</span></li></ol></div>
<p><strong>3. Apache+Resin组合的时候设置伪静态需要注意的地方</strong></p>
<p>二者组合中Resin主要完成Servlet所映射的地址为文件类型，而Apache完成其余部分，因此关于页面伪静态部分需要在Resin和Apache中同时设置才有效，否则有时候会出现404错误。但对于301永久重定向来说，如果是涉及域名部分的只需要在Apache中设置即可，如果二者都设置的时候会出现域名解析错误；如果涉及到页面部分的话需要在二者中都设置。</p>
<p>关于Resin如何同Apache组合请看这篇文章 <a href="http://www.javatang.com/archives/2006/08/21/010658.html" target="_blank">Resin 3.0.x 经验总结</a></p>
<p>关于Resin+Apache下如何设置泛域名请看这篇文章 <a href="http://www.javatang.com/archives/2008/03/18/2532264.html" target="_blank">Apache+Resin泛域名的设置</a></p>
<p>参考资料：<br />
<a href="http://www.caucho.com/resin/doc/rewrite-tags.xtp#moved-permanently" target="_blank">Resin url rewrite tags</a><br />
<a href="http://www.fosoo.cn/linux/16" target="_blank">Apache网站301永久重定向设置</a></p>
<div id="crp_related"><h2>Related Posts:</h2><ul><li><a href="http://www.javatang.com/archives/2007/06/20/1513177.html" rel="bookmark" class="crp_title">Apache和Resin产生大容量日志的解决办法</a></li><li><a href="http://www.javatang.com/archives/2008/03/18/2532264.html" rel="bookmark" class="crp_title">Apache+Resin泛域名的设置</a></li><li><a href="http://www.javatang.com/archives/2011/09/20/2831546.html" rel="bookmark" class="crp_title">Apache+Resin发布程序时一直出现403错误的解决办法</a></li><li><a href="http://www.javatang.com/archives/2006/08/21/010658.html" rel="bookmark" class="crp_title">Resin 3.0.x 经验总结</a></li><li><a href="http://www.javatang.com/archives/2010/08/27/3629451.html" rel="bookmark" class="crp_title">Apache和Resin组合时UrlRewriteFilter失效的解决方法</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.javatang.com/archives/2008/10/18/1942276.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache+Resin泛域名的设置</title>
		<link>http://www.javatang.com/archives/2008/03/18/2532264.html</link>
		<comments>http://www.javatang.com/archives/2008/03/18/2532264.html#comments</comments>
		<pubDate>Tue, 18 Mar 2008 15:25:32 +0000</pubDate>
		<dc:creator>Jet</dc:creator>
				<category><![CDATA[Web&Server]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[resin]]></category>

		<guid isPermaLink="false">http://www.javatang.com/archives/2008/03/18/2532264.html</guid>
		<description><![CDATA[在Apache中如果设置范域名的话使用 ServerAlias ，比如 &#60;VirtualHost *:80&#62; &#160; ServerName javatang.com &#160; ServerAlias *.javatang.com &#160; ... &#60;/VirtualHost&#62; 如果使用Apache+Resin架构的话，需要在Resin中设置同样的泛域名与Apache进行对应。在Resin中设置泛域名使用 host-alias-regexp 标签，对应于上面Apache在Resin中设置如下： &#60;host id=&#34;javatang.com&#34; root-directory=&#34;.&#34;&#62; &#160;&#160; &#60;host-alias-regexp&#62;^([^/]*).javatang.com&#60;/host-alias-regexp&#62; &#160;&#160; ... &#60;/host&#62; 参考资料： host-alias-regexp apache、resin泛域名、多域名设置 Related Posts:Resin中对日志输出的配置Apache+Resin下如何写伪静态和301跳转Apache整合Tomcat之后的优化Resin 3.0.x 经验总结实现WordPress的Permalinks]]></description>
			<content:encoded><![CDATA[<p>在Apache中如果设置范域名的话使用 ServerAlias ，比如</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">&lt;VirtualHost *:80&gt;</li>
<li>&nbsp; ServerName javatang.com</li>
<li>&nbsp; ServerAlias *.javatang.com</li>
<li>&nbsp; ...</li>
<li>&lt;/VirtualHost&gt;</li></ol></div>
<p>如果使用Apache+Resin架构的话，需要在Resin中设置同样的泛域名与Apache进行对应。在Resin中设置泛域名使用 host-alias-regexp 标签，对应于上面Apache在Resin中设置如下：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">&lt;host id=&quot;javatang.com&quot; root-directory=&quot;.&quot;&gt;</li>
<li>&nbsp;&nbsp; &lt;host-alias-regexp&gt;^([^/]*).javatang.com&lt;/host-alias-regexp&gt;</li>
<li>&nbsp;&nbsp; ...</li>
<li>&lt;/host&gt;</li></ol></div>
<p>参考资料：<br />
<a href="http://caucho.com/resin/doc/host-tags.xtp#host-alias-regexp" target="_blank">host-alias-regexp </a><br />
<a href="http://hi.baidu.com/mygia/blog/item/5c1bcafdaba44547d7887d1b.html" target="_blank">apache、resin泛域名、多域名设置</a></p>
<div id="crp_related"><h2>Related Posts:</h2><ul><li><a href="http://www.javatang.com/archives/2010/11/14/1752494.html" rel="bookmark" class="crp_title">Resin中对日志输出的配置</a></li><li><a href="http://www.javatang.com/archives/2008/10/18/1942276.html" rel="bookmark" class="crp_title">Apache+Resin下如何写伪静态和301跳转</a></li><li><a href="http://www.javatang.com/archives/2006/04/24/400519.html" rel="bookmark" class="crp_title">Apache整合Tomcat之后的优化</a></li><li><a href="http://www.javatang.com/archives/2006/08/21/010658.html" rel="bookmark" class="crp_title">Resin 3.0.x 经验总结</a></li><li><a href="http://www.javatang.com/archives/2006/03/14/14246.html" rel="bookmark" class="crp_title">实现WordPress的Permalinks</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.javatang.com/archives/2008/03/18/2532264.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Zend Optimizer 出错造成站点无法访问</title>
		<link>http://www.javatang.com/archives/2008/02/28/1713261.html</link>
		<comments>http://www.javatang.com/archives/2008/02/28/1713261.html#comments</comments>
		<pubDate>Thu, 28 Feb 2008 03:17:13 +0000</pubDate>
		<dc:creator>Jet</dc:creator>
				<category><![CDATA[Web&Server]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[iis]]></category>
		<category><![CDATA[zend optimizer]]></category>

		<guid isPermaLink="false">http://www.javatang.com/archives/2008/02/28/1713261.html</guid>
		<description><![CDATA[今天有朋友的服务器出现站点无法访问的状况，登录进去看到Apache占用了服务器的大部分内存导致服务器剩余内存很少，如果重启Apache的话依然无法释放内存，只有重启服务器之后才正常。 查看“事件查看器”中出现一个Zend Optimizer错误，而且这个错误都是每次启动服务器之后产生的： 事件类型: 错误 事件来源: Zend Optimizer 事件种类: 无 事件 ID: 487 日期: 2008-2-28 事件: 9:22:15 用户: N/A 计算机: XXX 描述: 事件 ID ( 487 )的描述(在资源( Zend Optimizer )中)无法找到。本地计算机可能没有必要的注册信息或消息 DLL 文件来从远程计算机显示消息。您可能可以使用 /AUXSOURCE= 标识来检索词描述；查看帮助和支持以了解详细信息。下列信息是事件的一部分: Unable to view file mapping, 试图访问无效的地址。 查阅了一下网上的资料，其实只有一个版本，具体内容可以看下面的参考资料。我这里结合自己的解决方法总结一下： 首先如果你的PHP使用了eAccelerator则将其注释掉就可以了，这是因为Zend Optimizer同eAccelerator相冲突。其实二者都是用于加速PHP程序的，只要使用其中的一个就可以了。 如果你的PHP没有使用eAccelerator的话则大部分是权限的问题了，这种情况在Apache+PHP中很少见，通常都是在IIS+PHP这种搭配中出现的比较多。这个时候只需要修改%SystemRoot%\Temp的权限，设置为EveryOne全部允许；然后如果该目录下没有ZendOptimizer.MemoryBase@SYSTEM文件的话就手动新建一个文本文件然后命名为ZendOptimizer.MemoryBase@SYSTEM即可。 如果还是有问题的话可以查看一下php下的ext目录中是否有php_yaz.dll和php_zip.dll两个文件，有哪一个就在php.ini将 “extension=&#8230;”前面的分号去掉。 做完上面的操作之后如果依然出现问题的话请在下面留言或给我mail，可以再继续探讨。 [后续(2008.3.4):]做完上述的操作之后依然出现上面的错误，不过错误出现的次数少了而已，最后不得已将Zend卸载掉了。现在感觉好像应该是Zend Optimizer的一个bug吧。 参考资料： 事件 ID ( 487 )的描述(在资源( [...]]]></description>
			<content:encoded><![CDATA[<p>今天有朋友的服务器出现站点无法访问的状况，登录进去看到Apache占用了服务器的大部分内存导致服务器剩余内存很少，如果重启Apache的话依然无法释放内存，只有重启服务器之后才正常。</p>
<p>查看“事件查看器”中出现一个Zend Optimizer错误，而且这个错误都是每次启动服务器之后产生的：</p>
<blockquote><p>
事件类型: 错误<br />
事件来源: Zend Optimizer<br />
事件种类: 无<br />
事件 ID: 487<br />
日期:     2008-2-28<br />
事件:     9:22:15<br />
用户:     N/A<br />
计算机: XXX<br />
描述:<br />
事件 ID ( 487 )的描述(在资源( Zend Optimizer )中)无法找到。本地计算机可能没有必要的注册信息或消息 DLL 文件来从远程计算机显示消息。您可能可以使用 /AUXSOURCE= 标识来检索词描述；查看帮助和支持以了解详细信息。下列信息是事件的一部分: Unable to view file mapping, 试图访问无效的地址。
</p></blockquote>
<p>查阅了一下网上的资料，其实只有一个版本，具体内容可以看下面的参考资料。我这里结合自己的解决方法总结一下：</p>
<p>首先如果你的PHP使用了eAccelerator则将其注释掉就可以了，这是因为Zend Optimizer同eAccelerator相冲突。其实二者都是用于加速PHP程序的，只要使用其中的一个就可以了。</p>
<p>如果你的PHP没有使用eAccelerator的话则大部分是权限的问题了，这种情况在Apache+PHP中很少见，通常都是在IIS+PHP这种搭配中出现的比较多。这个时候只需要修改%SystemRoot%\Temp的权限，设置为EveryOne全部允许；然后如果该目录下没有ZendOptimizer.MemoryBase@SYSTEM文件的话就手动新建一个文本文件然后命名为ZendOptimizer.MemoryBase@SYSTEM即可。</p>
<p>如果还是有问题的话可以查看一下php下的ext目录中是否有php_yaz.dll和php_zip.dll两个文件，有哪一个就在php.ini将 “extension=&#8230;”前面的分号去掉。</p>
<p>做完上面的操作之后如果依然出现问题的话请在下面留言或给我mail，可以再继续探讨。</p>
<p>[后续(2008.3.4):]做完上述的操作之后依然出现上面的错误，不过错误出现的次数少了而已，最后不得已将Zend卸载掉了。现在感觉好像应该是Zend Optimizer的一个bug吧。</p>
<p>参考资料：<br />
<a href="http://hi.baidu.com/%CB%CE%CF%FE%C1%C1/blog/item/95eb56e78a53f02cb93820e9.html" target="_blank">事件 ID ( 487 )的描述(在资源( Zend Optimizer )中)无法找到。</a><br />
<a href="http://hi.baidu.com/gushu/blog/item/2c2a544e61de190ab2de056d.html" target="_blank">解决“事件ID(487)的描述(在资源(Zend Optimizer)中)无法找到”问题</a></p>
<div id="crp_related"><h2>Related Posts:</h2><ul><li><a href="http://www.javatang.com/archives/2007/03/20/0534141.html" rel="bookmark" class="crp_title">PHP框架大展台</a></li><li><a href="http://www.javatang.com/archives/2007/06/12/5334171.html" rel="bookmark" class="crp_title">Zend Framework极好的起步教程</a></li><li><a href="http://www.javatang.com/archives/2007/06/21/2626179.html" rel="bookmark" class="crp_title">加速你的PHP程序</a></li><li><a href="http://www.javatang.com/archives/2007/06/10/3354167.html" rel="bookmark" class="crp_title">从PHP4升级到PHP5</a></li><li><a href="http://www.javatang.com/archives/2007/07/04/1548182.html" rel="bookmark" class="crp_title">PHP中出现“Unable to load dynamic library”问题的解决方法</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.javatang.com/archives/2008/02/28/1713261.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows NT系统下的Apache性能优化</title>
		<link>http://www.javatang.com/archives/2008/02/19/0801260.html</link>
		<comments>http://www.javatang.com/archives/2008/02/19/0801260.html#comments</comments>
		<pubDate>Tue, 19 Feb 2008 03:08:01 +0000</pubDate>
		<dc:creator>Jet</dc:creator>
				<category><![CDATA[Web&Server]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.javatang.com/archives/2008/02/19/0801260.html</guid>
		<description><![CDATA[一般来说，WinNT系统下使用IIS，而Apache在Linux下应用的比较多，但是依然有很多人在WinNT系统下使用Apache而非IIS，可能是基于对Windows系统的熟悉吧。今天就来说一下在Windows系统下如果优化Apache的性能。 mpm_winnt.c是专门针对Windows NT优化的MPM(多路处理模块)，它使用一个单独的父进程产生一个单独的子进程，在这个子进程中轮流产生多个线程来处理请求。也就是说mpm_winnt只能启动父子两个进程, 不能像Linux下那样同时启动多个进程。 mpm_winnt主要通过ThreadsPerChild和MaxRequestsPerChild两个参数来优化Apache，下面详细来说明一下。 ThreadsPerChild 这个参数用于设置每个进程的线程数, 子进程在启动时建立这些线程后就不再建立新的线程了. 一方面因为mpm_winnt不能启动多个进程, 所以这个数值要足够大，以便可以处理可能的请求高峰; 另一方面该参数以服务器的响应速度为准的, 数目太大的反而会变慢。因此需要综合均衡一个合理的数值。 mpm_winnt上的默认值是64, 最大值是1920. 这里建议设置为100-500之间，服务器性能高的话值大一些，反之值小一些。 MaxRequestsPerChild 该参数表示每个子进程能够处理的最大请求数, 即同时间内子进程数目.设置为零表示不限制, mpm_winnt上的默认值就是0. 官方参考手册中不建议设置为0, 主要基于两点考虑: (1) 可以防止(偶然的)内存泄漏无限进行，从而耗尽内存; (2) 给进程一个有限寿命，从而有助于当服务器负载减轻的时候减少活动进程的数量。 因此这个参数的值更大程度上取决于服务器的内存，如果内存比较大的话可以设置为0或很大的数字，否则设置一个小的数值。需要说明的是，如果这个值设置的太小的话会造成Apache频繁重启，在日志文件中会看到如下的文字： Process exiting because it reached MaxRequestsPerChild. Signaling the parent 这样一来降低了Apache的总体性能。 另外，可以通过查看Apache提供的server-status(状态报告)来验证当前所设置数值是否合理，在httpd.conf文件中做如下设置来打开它： # 首先需要加载mod_status模块 LoadModule status_module modules/mod_status.so &#160; # 然后设置访问的地址 &#60;Location /server-status&#62; &#160;&#160; &#160;SetHandler server-status &#160;&#160; &#160;Order deny,allow &#160;&#160; &#160;Deny [...]]]></description>
			<content:encoded><![CDATA[<p>一般来说，WinNT系统下使用IIS，而Apache在Linux下应用的比较多，但是依然有很多人在WinNT系统下使用Apache而非IIS，可能是基于对Windows系统的熟悉吧。今天就来说一下在Windows系统下如果优化Apache的性能。</p>
<p><strong>mpm_winnt.c</strong>是专门针对Windows NT优化的MPM(多路处理模块)，它使用一个单独的父进程产生一个单独的子进程，在这个子进程中轮流产生多个线程来处理请求。也就是说mpm_winnt只能启动父子两个进程, 不能像Linux下那样同时启动多个进程。</p>
<p>mpm_winnt主要通过ThreadsPerChild和MaxRequestsPerChild两个参数来优化Apache，下面详细来说明一下。</p>
<p><strong>ThreadsPerChild</strong><br />
这个参数用于设置每个进程的线程数, 子进程在启动时建立这些线程后就不再建立新的线程了. 一方面因为mpm_winnt不能启动多个进程, 所以这个数值要足够大，以便可以处理可能的请求高峰; 另一方面该参数以服务器的响应速度为准的, 数目太大的反而会变慢。因此需要综合均衡一个合理的数值。</p>
<p>mpm_winnt上的默认值是64, 最大值是1920. 这里建议设置为100-500之间，服务器性能高的话值大一些，反之值小一些。</p>
<p><strong>MaxRequestsPerChild</strong><br />
该参数表示每个子进程能够处理的最大请求数, 即同时间内子进程数目.设置为零表示不限制, mpm_winnt上的默认值就是0. </p>
<p>官方参考手册中不建议设置为0, 主要基于两点考虑: (1) 可以防止(偶然的)内存泄漏无限进行，从而耗尽内存; (2) 给进程一个有限寿命，从而有助于当服务器负载减轻的时候减少活动进程的数量。</p>
<p>因此这个参数的值更大程度上取决于服务器的内存，如果内存比较大的话可以设置为0或很大的数字，否则设置一个小的数值。需要说明的是，如果这个值设置的太小的话会造成Apache频繁重启，在日志文件中会看到如下的文字：</p>
<blockquote><p>Process exiting because it reached MaxRequestsPerChild. Signaling the parent</p></blockquote>
<p>这样一来降低了Apache的总体性能。</p>
<p>另外，可以通过查看Apache提供的server-status(状态报告)来验证当前所设置数值是否合理，在httpd.conf文件中做如下设置来打开它：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"># 首先需要加载mod_status模块</li>
<li>LoadModule status_module modules/mod_status.so</li>
<li>&nbsp;</li>
<li># 然后设置访问的地址</li>
<li>&lt;Location /server-status&gt;</li>
<li>&nbsp;&nbsp; &nbsp;SetHandler server-status</li>
<li>&nbsp;&nbsp; &nbsp;Order deny,allow</li>
<li>&nbsp;&nbsp; &nbsp;Deny from all</li>
<li>&nbsp;&nbsp; &nbsp;# 如果限制某个IP访问则设置为 Allow from 192.168.1.1</li>
<li>&nbsp;&nbsp; &nbsp;Allow from all</li>
<li>&lt;/Location&gt;</li></ol></div>
<p>综合来说，因为Windows NT下Apache只能启动父子两个进程，因此只能通过增大单个进程的线程数以及单个进程能够处理的最大请求数来进行优化。其他优化的参数同Linux系统下是一样的，大家可以加以参考。下面针对上述两个参数给出一个建议的设置：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">&lt;IfModule mpm_winnt.c&gt;</li>
<li>&nbsp; ThreadsPerChild 250</li>
<li>&nbsp; MaxRequestsPerChild 5000</li>
<li>&lt;/IfModule&gt;</li></ol></div>
<p>参考资料：<br />
Apache参考手册<br />
<a href="http://www.phpchina.com/manual/apache/mod/mod_status.html" target="_blank">Apache模块 mod_status</a></p>
<div id="crp_related"><h2>Related Posts:</h2><ul><li><a href="http://www.javatang.com/archives/2006/03/17/282911.html" rel="bookmark" class="crp_title">Apache2安全配置</a></li><li><a href="http://www.javatang.com/archives/2008/01/22/0615259.html" rel="bookmark" class="crp_title">解决Apache出现的CPU高占用率的问题</a></li><li><a href="http://www.javatang.com/archives/2007/03/30/1025157.html" rel="bookmark" class="crp_title">Windows下安装zip包版本的MySQL</a></li><li><a href="http://www.javatang.com/archives/2007/10/30/2016233.html" rel="bookmark" class="crp_title">C++基础之字符串处理函数</a></li><li><a href="http://www.javatang.com/archives/2008/10/18/1942276.html" rel="bookmark" class="crp_title">Apache+Resin下如何写伪静态和301跳转</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.javatang.com/archives/2008/02/19/0801260.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>解决Apache出现的CPU高占用率的问题</title>
		<link>http://www.javatang.com/archives/2008/01/22/0615259.html</link>
		<comments>http://www.javatang.com/archives/2008/01/22/0615259.html#comments</comments>
		<pubDate>Tue, 22 Jan 2008 22:06:15 +0000</pubDate>
		<dc:creator>Jet</dc:creator>
				<category><![CDATA[Web&Server]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[cpu100%]]></category>

		<guid isPermaLink="false">http://www.javatang.com/archives/2008/01/22/0615259.html</guid>
		<description><![CDATA[所谓Apache出现CPU高占用率就是指Apache在一段时间内持续占用很高的CPU使用率，甚至达到CPU100％，这个时候造成网站无法访问。解决的方法就是仔细观察Apache的日志文件，查阅错误的信息。 下面我们针对几种错误信息进行分析并给出解决的方法： 1. Apache与WinSock v2相冲突 Apache官方提供的手册中提到，在Windows系统下Apache2.x为了提高性能而使用了Microsoft WinSock v2 API，但是一些常见的防火墙软件会破坏他的正确性，从而使得Apache出现死循环操作造成CPU100％。 其错误提示如下所示： [error] (730038)An operation was attempted on something that is not a socket.: winnt_accept: AcceptEx failed. Attempting to recover. [error] (OS 10038) : Child 3356: Encountered too many errors accepting client connections. Possible causes: dynamic address renewal, or incompatible VPN or firewall software. Try using the [...]]]></description>
			<content:encoded><![CDATA[<p>所谓Apache出现CPU高占用率就是指Apache在一段时间内持续占用很高的CPU使用率，甚至达到CPU100％，这个时候造成网站无法访问。解决的方法就是仔细观察Apache的日志文件，查阅错误的信息。</p>
<p>下面我们针对几种错误信息进行分析并给出解决的方法：</p>
<p><strong>1. Apache与WinSock v2相冲突</strong><br />
<a href="http://httpd.apache.org/docs/2.0/mod/mpm_winnt.html" target="_blank">Apache官方提供的手册</a>中提到，在Windows系统下Apache2.x为了提高性能而使用了Microsoft WinSock v2 API，但是一些常见的防火墙软件会破坏他的正确性，从而使得Apache出现死循环操作造成CPU100％。</p>
<p>其错误提示如下所示：</p>
<blockquote><p>[error] (730038)An operation was attempted on something that is not a socket.: winnt_accept: AcceptEx failed. Attempting to recover. </p></blockquote>
<blockquote><p>[error] (OS 10038) : Child 3356: Encountered too many errors accepting client connections. Possible causes: dynamic address renewal, or incompatible VPN or firewall software. Try using the Win32DisableAcceptEx directive. </p></blockquote>
<blockquote><p>[warn] (OS 121)信号灯超时时间已到。 : winnt_accept: Asynchronous AcceptEx failed.</p></blockquote>
<blockquote><p>[warn] (OS 64)指定的网络名不再可用。  : winnt_accept: Asynchronous AcceptEx failed.</p></blockquote>
<p>可以依次采用下面的方法来解决上面的问题，如果进行了一步还有问题就继续下一步：</p>
<p>1) 在httpd.conf文件中使用 Win32DisableAcceptEx 禁止Apache使用 Microsoft WinSock v2 API ：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">&lt;IfModule mpm_winnt.c&gt; </li>
<li>Win32DisableAcceptEx # 禁止使用AcceptEx()</li>
<li>&lt;/IfModule&gt;</li></ol></div>
<p>2) 使用<a href="http://www.kztechs.com/sreng/download.html" target="_blank">System Repair Engineer(SREng)</a>查看WinSocket供应者，如果出现非MS的陌生项则将其删除，并使用软件的“重置WinSocket”按钮进行重置。</p>
<p>3) 卸载与Apache相冲突的杀毒软件或防火墙软件。</p>
<p>如果进行上面的三个步骤之后还有问题，那应该看看是不是还有下面的错误。</p>
<p><strong>2. 是否加载了第三方模块(so文件)</strong><br />
Apache2.x要求所有的第三方模块都必须是线程安全的，但有很多第三方的模块可能存在内存泄露，因此时间一长就可以极大的消耗Apache资源。所以可以采用将所有的第三方模块逐个关闭的方法看看运行一段时间之后Apache对资源的占用是否有所改善。</p>
<p><strong>3. “Terminating 1 threads that failed to exit”错误</strong><br />
上面错误中的数字1有可能是其他数字，造成这个错误的原因是Apache在关闭并发线程的时候出现线程溢出，从而造成内存泄露，表现出来的就是Apache所占用的系统资源持续增长。</p>
<p>具体来说，Apache的子进程在结束当前请求之前会首先将所有的并发线程进行关闭，在关闭的时候会等待3分钟，如果3分钟之内没有将所有的线程关闭则会抛出上述的错误提示，然后强制关闭。这样就造成了内存溢出，时间一长会使得Apache所占用资源持续增长直到无法工作。这个时候可以适当将<a href="http://www.javatang.com/index.php?s=MaxRequestsPerChild">MaxRequestsPerChild</a>的值降低，使得Apache子进程所并发的线程数量减少，从而降低该错误出现的几率。</p>
<p>但是这种方式并不能彻底解决问题，幸好Apache2.0.x的最新版本(2.0.63)解决了之前版本的这个问题，如果3分钟之内有线程没有关闭的话会自动根据时间情况再增加等待结束的时间直到最终将所有的线程结束。日志文件中会出现类似下面的信息：</p>
<blockquote><p>
Child 1952: Waiting 150 more seconds for 2 worker threads to finish.<br />
Child 1952: Waiting 120 more seconds for 1 worker threads to finish.<br />
Child 1952: All worker threads have exited.
</p></blockquote>
<p><strong>4. “file .\\server\\mpm\\winnt\\child.c, line 1078, assertion “(rv &gt;= 0) &#038;&#038; (rv &lt; threads_created)” failed” 错误</strong></p>
<p>这个错误是Apache的一个<a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=11997" target="_blank">bug(#11997)</a>，可以通过 Win32DisableAcceptEx 禁止Apache使用WinSocket v2来避免此bug，具体设置见前述。</p>
<p><strong>5. PHP5.2.1以上版本的libmysql.dll与MySQL5不兼容</strong><br />
PHP5.2.1以后的新版本(截止目前最新版本为5.2.5)中用于连接MySQL的libmysql.dll组件与MySQL5不兼容，在Apache中运行PHP的时候会造成Apache产生CPU100%的问题。</p>
<p>解决的方法就是从<a href="http://www.php.net/releases/" target="_blank">http://www.php.net/releases/</a>下载5.2.1版本，将压缩包中的libmysql.dll文件覆盖现在的文件，然后重启Apache就可以了。</p>
<p><strong>6. 病毒或木马程序命名为Apache.exe</strong><br />
有的时候病毒或木马程序会将其名称命名为Apache.exe文件达到一种掩饰的目的，这个时候使用第三方进程分析器查看进程的路径然后将其删除或使用杀毒软件清除就可以了。</p>
<p><strong>7. 程序编写不严谨造成死循环等错误</strong><br />
如果上面的问题都不存在Apache依然产生CPU100%的问题的话，通常来说就应该是Web程序自身的问题了，例如死循环等等。这个时候需要在日志中设置HTTP请求的文件及执行的时间，然后查找出执行时间比较长的地址进行分析排查。</p>
<p>日志格式设置如下：</p>
<blockquote><p>
LogFormat “%v %h %l %u %t [%Ts] \”%r\” %>s %b” vhost_common #设置程序执行时间</p>
<p>&lt;VirtualHost xxx.xxx.xx.xx:80&gt;<br />
  ServerName xxx.xxx.com<br />
  DirectoryIndex index.php index.html index.htm<br />
  DocumentRoot “xxx”<br />
  # cronolog.exe用于将日志文件进行分割的应用程序，可以在 http://cronolog.org/ 下载<br />
  CustomLog “|bin/cronolog.exe e:/%Y%m%d.log” vhost_common<br />
&lt;/VirtualHost&gt;</p>
</blockquote>
<p>参考资料：<br />
<a href="http://groups.google.com/group/eachgain/browse_thread/thread/203204184f99e544/339ae75ba239e064%23339ae75ba239e064" target="_blank">apache 遇到[error] (OS 10038) 错误</a><br />
<a href="https://support.kayako.com/index.php?_m=knowledgebase&#038;_a=viewarticle&#038;kbarticleid=236" target="_blank">Error in my_thread_global_end(): 1 threads didn&#8217;t exit</a><br />
<a href="http://www.apachelounge.com/forum/viewtopic.php?p=9680#9680" target="_blank">Apache 2.2.x (ASF) faulting module errors</a><br />
<a href="http://www.apachelounge.com/forum/viewtopic.php?p=8153#8153" target="_blank">Need some advice on Apache 2.2.4 PHP 5.2.3 MYSQL 4.0.26</a><br />
<a href="http://blog.s135.com/read.php/269.htm?page=1" target="_blank">查看Apache并发请求数及其TCP连接状态</a><br />
<a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=11997" target="_blank">Apache Bug 11997</a><br />
<a href="http://zhumeng99.cn/read.php?48" target="_blank">关于apache.exe开机占用cpu100%的终极解决方法</a><br />
<a href="http://riddle.bokee.com/6200980.html" target="_blank">apache cpu占用100%的问题。</a><br />
<a href="http://x.discuz.net/viewthread-609579.html" target="_blank">空间持续CPU100%时间过长，如何优化程序</a></p>
<div id="crp_related"><h2>Related Posts:</h2><ul><li><a href="http://www.javatang.com/archives/2007/06/20/1513177.html" rel="bookmark" class="crp_title">Apache和Resin产生大容量日志的解决办法</a></li><li><a href="http://www.javatang.com/archives/2008/02/19/0801260.html" rel="bookmark" class="crp_title">Windows NT系统下的Apache性能优化</a></li><li><a href="http://www.javatang.com/archives/2006/03/17/282911.html" rel="bookmark" class="crp_title">Apache2安全配置</a></li><li><a href="http://www.javatang.com/archives/2006/08/21/010658.html" rel="bookmark" class="crp_title">Resin 3.0.x 经验总结</a></li><li><a href="http://www.javatang.com/archives/2007/06/10/3354167.html" rel="bookmark" class="crp_title">从PHP4升级到PHP5</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.javatang.com/archives/2008/01/22/0615259.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: www.javatang.com @ 2012-02-10 07:36:49 -->
