<?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>OurApache &#187; Apache解错方案</title>
	<atom:link href="http://ourapache.com/archives/category/debug/feed" rel="self" type="application/rss+xml" />
	<link>http://ourapache.com</link>
	<description>我们致力于一个Apache知识的分享网站</description>
	<lastBuildDate>Tue, 13 Apr 2010 05:18:24 +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>解决linux下安装ssl后，apache重启时需要密码</title>
		<link>http://ourapache.com/archives/326</link>
		<comments>http://ourapache.com/archives/326#comments</comments>
		<pubDate>Tue, 13 Apr 2010 05:18:24 +0000</pubDate>
		<dc:creator>OurApache</dc:creator>
				<category><![CDATA[Apache解错方案]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[密码]]></category>

		<guid isPermaLink="false">http://www.ourapache.com/?p=326</guid>
		<description><![CDATA[解决linux下安装ssl后，apache重启时需要密码的问题。]]></description>
			<content:encoded><![CDATA[<p><strong>解决linux下安装ssl后，apache重启时需要密码的问题。</strong></p>
<p>在帮客户购买的vps上面<a href="http://www.kuaissl.com/support/SSLins/Apache_ins.htm">安装完SSL</a>以后，每次启动apache时都需要输入密码，觉得维护起来非常的麻烦。</p>
<p>客户的vps是ubuntu Sever，其他linux服务器找到相关文件修改</p>
<p>编辑：<a href="http://ourapache.com/archives/tag/ssl" class="st_tag internal_tag" rel="tag" title="标签 ssl 下的日志">ssl</a>.conf ,</p>
<p>ubuntu下面的目录：</p>
<p>/etc/apache2/mods-available/ssl.conf</p>
<p>修改ssl.conf</p>
<p># SSLPassPhraseDialog builtin</p>
<p>SSLPassPhraseDialog exec:/ect/apache2/key.sh</p>
<p>编辑：/ect/apache2/key.sh</p>
<p>!/bin/bash</p>
<p>echo ‘your pass phrase’</p>
<p>注意key.sh的权限755</p>
<p>重启服务器</p>
<p>问题解决</p>
<h3  class="related_post_title">无相关文章，以下随机显示</h3><ul class="related_post"><li>2009年02月7号 -- <a href="http://ourapache.com/archives/97" title="使用apache下的301设置来做域名的更换转移">使用apache下的301设置来做域名的更换转移</a></li><li>2009年01月15号 -- <a href="http://ourapache.com/archives/38" title="Apache服务器安全防范">Apache服务器安全防范</a></li><li>2009年02月25号 -- <a href="http://ourapache.com/archives/172" title="查询并禁止apache中异常访问量的用户">查询并禁止apache中异常访问量的用户</a></li><li>2009年02月25号 -- <a href="http://ourapache.com/archives/181" title="Apache并发控制、查看进程数、TCP连接、压缩功能说明">Apache并发控制、查看进程数、TCP连接、压缩功能说明</a></li><li>2009年02月10号 -- <a href="http://ourapache.com/archives/106" title="Apache Rewrite 规则详解">Apache Rewrite 规则详解</a></li><li>2009年01月22号 -- <a href="http://ourapache.com/archives/66" title="Apache配置文件(httpd.conf)中文说明">Apache配置文件(httpd.conf)中文说明</a></li><li>2009年03月9号 -- <a href="http://ourapache.com/archives/224" title="监视并记录Apache网站服务器的运行">监视并记录Apache网站服务器的运行</a></li><li>2009年08月13号 -- <a href="http://ourapache.com/archives/281" title="Linux下Apache并发连接数和带宽控制">Linux下Apache并发连接数和带宽控制</a></li><li>2009年01月5号 -- <a href="http://ourapache.com/archives/21" title="关于keepalive的解释">关于keepalive的解释</a></li><li>2009年02月7号 -- <a href="http://ourapache.com/archives/92" title="在Apache下限制每个虚拟主机的并发数">在Apache下限制每个虚拟主机的并发数</a></li></ul>
	标签：<a href="http://ourapache.com/archives/category/debug" title="Apache解错方案" rel="tag">Apache解错方案</a>, <a href="http://ourapache.com/archives/tag/ssl" title="ssl" rel="tag">ssl</a>, <a href="http://ourapache.com/archives/tag/%e5%af%86%e7%a0%81" title="密码" rel="tag">密码</a><br />
]]></content:encoded>
			<wfw:commentRss>http://ourapache.com/archives/326/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>在64位机器上关于Apache 2.2.3版的编译问题</title>
		<link>http://ourapache.com/archives/142</link>
		<comments>http://ourapache.com/archives/142#comments</comments>
		<pubDate>Tue, 17 Feb 2009 04:39:06 +0000</pubDate>
		<dc:creator>OurApache</dc:creator>
				<category><![CDATA[Apache解错方案]]></category>
		<category><![CDATA[64位]]></category>
		<category><![CDATA[编译]]></category>

		<guid isPermaLink="false">http://www.ourapache.com/?p=142</guid>
		<description><![CDATA[2.2.3版的apache在64位机器上进行编译会出现错误]]></description>
			<content:encoded><![CDATA[<p>2.2.3版的apache在64位机器上进行编译会出现如下错误：</p>
<blockquote><p>usr/lib/libexpat.so: could not read symbols: File in wrong format<br />
collect2: ld returned 1 exit status<br />
make[3]: *** [libaprutil-1.la] 错误 1<br />
make[3]: Leaving directory `/root/tar/httpd-2.2.3/srclib/apr-util&#8217;<br />
make[2]: *** [all-recursive] 错误 1<br />
make[2]: Leaving directory `/root/tar/httpd-2.2.3/srclib/apr-util&#8217;<br />
make[1]: *** [all-recursive] 错误 1<br />
make[1]: Leaving directory `/root/tar/httpd-2.2.3/srclib&#8217;<br />
make: *** [all-recursive] 错误 1<br />
 </p></blockquote>
<p>错误的解决方法可以参考邮件：<a href="http://www.mail-archive.com/bugs@httpd.apache.org/msg24675.html">http://www.mail-archive.com/bugs@httpd.apache.org/msg24675.html</a></p>
<p>具体的做法如下：<br />
1 setenv LDFLAGS “-L/usr/lib64 -L/lib64&#8243;    [用于csh，其他shell请用export命令]<br />
2 ./configure 时加入 &#8211;libdir=/usr/lib64 参数<br />
3 修改./srclib/apr-util/下的Makefile 改 APRUTIL_LIBS 的值中的”/usr/lib/libexpat.la” 为 “/usr/lib64/libexpat.la”<br />
然后进行编译。</p>
<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li>2009年08月13号 -- <a href="http://ourapache.com/archives/286" title="linux下查看nginx，apache，mysql，php的编译参数">linux下查看nginx，apache，mysql，php的编译参数</a></li><li>2009年06月7号 -- <a href="http://ourapache.com/archives/251" title="apxs是Apache编译和安装扩展模块的工具">apxs是Apache编译和安装扩展模块的工具</a></li><li>2008年12月27号 -- <a href="http://ourapache.com/archives/13" title="单独编译apache的rewrite模块">单独编译apache的rewrite模块</a></li></ul>
	标签：<a href="http://ourapache.com/archives/tag/64%e4%bd%8d" title="64位" rel="tag">64位</a>, <a href="http://ourapache.com/archives/category/debug" title="Apache解错方案" rel="tag">Apache解错方案</a>, <a href="http://ourapache.com/archives/tag/%e7%bc%96%e8%af%91" title="编译" rel="tag">编译</a><br />
]]></content:encoded>
			<wfw:commentRss>http://ourapache.com/archives/142/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>让apache支持自定义404页面错误</title>
		<link>http://ourapache.com/archives/136</link>
		<comments>http://ourapache.com/archives/136#comments</comments>
		<pubDate>Thu, 12 Feb 2009 08:09:48 +0000</pubDate>
		<dc:creator>OurApache</dc:creator>
				<category><![CDATA[Apache解错方案]]></category>
		<category><![CDATA[404]]></category>
		<category><![CDATA[rewrite]]></category>

		<guid isPermaLink="false">http://www.ourapache.com/?p=136</guid>
		<description><![CDATA[在rewrite开启的情况下，当URL发起请求的页面在服务器端不存在的时候，返回http status code ==400;
而通常文件没有找到应该返回404状态码，查询N久无解中，关闭rewrite一切正常]]></description>
			<content:encoded><![CDATA[<p>在rewrite开启的情况下，当URL发起请求的页面在服务器端不存在的时候，返回http status code ==400;<br />
而通常文件没有找到应该返回404状态码，查询N久无解中，关闭rewrite一切正常</p>
<p>在VirtualHost内部使用 ErrorDocument <a href="http://ourapache.com/archives/tag/404" class="st_tag internal_tag" rel="tag" title="标签 404 下的日志">404</a> /notfound.<a href="http://ourapache.com/archives/tag/php" class="st_tag internal_tag" rel="tag" title="标签 php 下的日志">php</a>  当服务器响应为404的时候会自动跳转到notfound.<a href="http://ourapache.com/archives/tag/php" class="st_tag internal_tag" rel="tag" title="标签 php 下的日志">php</a><br />
为了适应多种浏览器的不同 /notfound.php最好使用绝对的HTTP开头，如：http://blog.daxi8.cn/notfound.php</p>
<p>可以使用 .htaccess文件关闭 RewriteEngine Off 来关闭在此目录的rewrite模块</p>
<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li>2009年06月14号 -- <a href="http://ourapache.com/archives/255" title="常见的rewrite规则大全">常见的rewrite规则大全</a></li><li>2009年02月16号 -- <a href="http://ourapache.com/archives/140" title="Apache、resin、rewrite泛域名、多域名设置">Apache、resin、rewrite泛域名、多域名设置</a></li><li>2009年02月10号 -- <a href="http://ourapache.com/archives/106" title="Apache Rewrite 规则详解">Apache Rewrite 规则详解</a></li><li>2009年02月7号 -- <a href="http://ourapache.com/archives/85" title="apache之404错误页面">apache之404错误页面</a></li><li>2008年12月27号 -- <a href="http://ourapache.com/archives/13" title="单独编译apache的rewrite模块">单独编译apache的rewrite模块</a></li></ul>
	标签：<a href="http://ourapache.com/archives/tag/404" title="404" rel="tag">404</a>, <a href="http://ourapache.com/archives/category/debug" title="Apache解错方案" rel="tag">Apache解错方案</a>, <a href="http://ourapache.com/archives/tag/rewrite" title="rewrite" rel="tag">rewrite</a><br />
]]></content:encoded>
			<wfw:commentRss>http://ourapache.com/archives/136/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>apache core段的DocumentRoot与访问权限</title>
		<link>http://ourapache.com/archives/132</link>
		<comments>http://ourapache.com/archives/132#comments</comments>
		<pubDate>Thu, 12 Feb 2009 07:00:18 +0000</pubDate>
		<dc:creator>OurApache</dc:creator>
				<category><![CDATA[Apache解错方案]]></category>
		<category><![CDATA[DocumentRoot]]></category>
		<category><![CDATA[权限]]></category>

		<guid isPermaLink="false">http://www.ourapache.com/?p=132</guid>
		<description><![CDATA[设置Apache的虚拟主机时的路径权限要仔细 ]]></description>
			<content:encoded><![CDATA[<p align="left">Tips:</p>
<p>设置Apache的虚拟主机时的路径权限要仔细</p>
<p align="left">虚拟主机段配置如下：</p>
<blockquote>
<p align="left">NameVirtualHost *:80<br />
&lt;VirtualHost *:80&gt; <br />
        ServerAdmin zhao@sst.cn <br />
        <a href="http://ourapache.com/archives/tag/documentroot" class="st_tag internal_tag" rel="tag" title="标签 DocumentRoot 下的日志">DocumentRoot</a> /somewhere/ww1 <br />
        ServerName ww1.sst.cn <br />
        ErrorLog logs/ww1.sst.cn-error_log <br />
        CustomLog logs/ww1.sst.cn-access_log common<br />
&lt;/VirtualHost&gt;<br />
&lt;VirtualHost *:80&gt; <br />
        ServerName ww2.sst.cn <br />
        DocumentRoot /somewhere/ww2<br />
&lt;/VirtualHost&gt;</p>
</blockquote>
<p>当apache core段的DocumentRoot 值设为/somewhere/ww1时，</p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="284" valign="top">
<p align="left">访问ww1.sst.cn</p>
</td>
<td width="284" valign="top">
<p align="left">通过</p>
</td>
</tr>
<tr>
<td width="284" valign="top">
<p align="left">访问ww2.sst.cn</p>
</td>
<td width="284" valign="top">
<p align="left">Forbiddden</p>
</td>
</tr>
</tbody>
</table>
<p align="left">当apache core段的DocumentRoot 值设为/somewhere时，</p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="284" valign="top">
<p align="left">访问ww1.sst.cn</p>
</td>
<td width="284" valign="top">
<p align="left">通过</p>
</td>
</tr>
<tr>
<td width="284" valign="top">
<p align="left">访问ww2.sst.cn</p>
</td>
<td width="284" valign="top">
<p align="left">通过</p>
</td>
</tr>
</tbody>
</table>
<p align="left">  分析下来禁止访问产生的原因，是httpd.conf中对相应Directory段没有增加定义，如上例，如果核心DocumentRoot（/somewhere/ww1）不是接下来定义的虚拟主机中的DocumentRoot（/somewhere/ww2）的父目录，则需要增加定义虚拟主机自有的DocumentRoot（/somewhere/ww2）其相应的Directory定义：</p>
<blockquote>
<p align="left">&lt;Directory /somewhere/ww2&gt;</p>
<p align="left">    Options FollowSymLinks</p>
<p align="left">    AllowOverride None</p>
<p align="left">&lt;/Directory&gt;</p>
</blockquote>
<p align="left">自己提醒自己千万要仔细，吃了两次亏，还是忘记。</p>
<h3  class="related_post_title">无相关文章，以下随机显示</h3><ul class="related_post"><li>2009年02月10号 -- <a href="http://ourapache.com/archives/111" title="Apache 中内存管理的三种境界 ">Apache 中内存管理的三种境界 </a></li><li>2009年02月7号 -- <a href="http://ourapache.com/archives/97" title="使用apache下的301设置来做域名的更换转移">使用apache下的301设置来做域名的更换转移</a></li><li>2009年02月6号 -- <a href="http://ourapache.com/archives/76" title="Apache 模块说明">Apache 模块说明</a></li><li>2009年02月25号 -- <a href="http://ourapache.com/archives/163" title="apache 的mime.types文件">apache 的mime.types文件</a></li><li>2009年02月27号 -- <a href="http://ourapache.com/archives/190" title="header Content-Disposition参数说明">header Content-Disposition参数说明</a></li><li>2009年02月10号 -- <a href="http://ourapache.com/archives/106" title="Apache Rewrite 规则详解">Apache Rewrite 规则详解</a></li><li>2009年08月13号 -- <a href="http://ourapache.com/archives/284" title="Apache负载均衡设置方法: mod_proxy">Apache负载均衡设置方法: mod_proxy</a></li><li>2009年06月14号 -- <a href="http://ourapache.com/archives/255" title="常见的rewrite规则大全">常见的rewrite规则大全</a></li><li>2008年12月27号 -- <a href="http://ourapache.com/archives/9" title="apache禁止使用IP访问的实现方法">apache禁止使用IP访问的实现方法</a></li><li>2009年06月1号 -- <a href="http://ourapache.com/archives/243" title="玩转apache之日志">玩转apache之日志</a></li></ul>
	标签：<a href="http://ourapache.com/archives/category/debug" title="Apache解错方案" rel="tag">Apache解错方案</a>, <a href="http://ourapache.com/archives/tag/documentroot" title="DocumentRoot" rel="tag">DocumentRoot</a>, <a href="http://ourapache.com/archives/tag/%e6%9d%83%e9%99%90" title="权限" rel="tag">权限</a><br />
]]></content:encoded>
			<wfw:commentRss>http://ourapache.com/archives/132/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>apache 无法启动故障排查</title>
		<link>http://ourapache.com/archives/121</link>
		<comments>http://ourapache.com/archives/121#comments</comments>
		<pubDate>Tue, 10 Feb 2009 07:15:34 +0000</pubDate>
		<dc:creator>OurApache</dc:creator>
				<category><![CDATA[Apache解错方案]]></category>
		<category><![CDATA[startssl]]></category>
		<category><![CDATA[信号量]]></category>

		<guid isPermaLink="false">http://www.ourapache.com/?p=121</guid>
		<description><![CDATA[今天在F5上逛，发现某个ip下面的机器的80和443端口down了。
于是手动重启，结果发现apachectl start,可以正常启动，apachectl startssl却不行
使用ipcs查看系统的信号量，发现是信号量sem已经满了，所以导致startssl无法启动。
据说是如果apache没有正常Stop掉的话，它的信号量是不会自动清除的，导致其一直滞留在内存中]]></description>
			<content:encoded><![CDATA[<div>今天在F5上逛，发现某个ip下面的机器的80和443端口down了。</div>
<div>于是手动重启，结果发现apachectl start,可以正常启动，apachectl startssl却不行<br />
查看log</div>
<div>
<div>
<div style="font-size: 10pt; width: 98%; color: #000000; word-break: break-all; line-height: 16px; font-family: verdana,宋体; background-color: #eeeeee; border: #cccccc 1px solid; padding: 4px;">[Wed Apr 16 08:54:52 2008] [warn] pid file /usr/local/apache/logs/httpd.pid overwritten &#8212; Unclean shutdown of previous Apache run?<br />
[Fri Jun 13 11:59:24 2008] [alert] httpd: Could not determine the server&#8217;s fully qualified domain name, using 127.0.0.1 for ServerName<br />
semget: 设备上没有空间</div>
</div>
</div>
<div>
网上查了半天也无解。试图删除/usr/local/apache/logs/httpd.pid再重启也不行。<br />
问同事才知道</div>
<div>使用ipcs查看系统的信号量，发现是信号量sem已经满了，所以导致startssl无法启动。</div>
<div>据说是如果apache没有正常Stop掉的话，它的信号量是不会自动清除的，导致其一直滞留在内存中</div>
<div>于是，用以下命令清除sem信号量后，apache就可以正常启动了：</div>
<div>
<div>
<div style="font-size: 10pt; width: 98%; color: #000000; word-break: break-all; line-height: 16px; font-family: verdana,宋体; background-color: #eeeeee; border: #cccccc 1px solid; padding: 4px;">for i in `ipcs  | grep nobody | awk &#8216;{print $2}&#8217;`; do ipcrm -s $i; done</div>
</div>
</div>
<div>
看来，以后我们需要慎用killall -9 httpd，尽量使apache能正常的stop</div>
<div>
<div>
<div style="font-size: 10pt; width: 98%; color: #000000; word-break: break-all; line-height: 16px; font-family: verdana,宋体; background-color: #eeeeee; border: #cccccc 1px solid; padding: 4px;">[root@l_192_168_131_164 log]# ipcs<br />
&#8212;&#8212; Shared Memory Segments &#8212;&#8212;&#8211;<br />
key        shmid      owner      perms      bytes      nattch     status      <br />
0&#215;00000000 7143424    root      600        184324     74         dest          <br />
&#8212;&#8212; Semaphore Arrays &#8212;&#8212;&#8211;<br />
key        semid      owner      perms      nsems      <br />
0&#215;00000000 0          nobody    600        1          <br />
0&#215;00000000 32769      nobody    600        1          <br />
0&#215;00000000 65538      nobody    600        1          <br />
。。。。。。。。。<br />
。。。。。。。。。<br />
0&#215;00000000 98307      nobody    600        1          <br />
&#8212;&#8212; Message Queues &#8212;&#8212;&#8211;<br />
key        msqid      owner      perms      used-bytes   messages  </div>
</div>
<p>可以看到很多<br />
清除了就可以了<br />
for i in `ipcs  | grep nobody | awk &#8216;{print $2}&#8217;`; do ipcrm -s $i; done</p></div>
<div>然后再查看</p>
<div>
<div style="font-size: 10pt; width: 98%; color: #000000; word-break: break-all; line-height: 16px; font-family: verdana,宋体; background-color: #eeeeee; border: #cccccc 1px solid; padding: 4px;">[root@l_192_168_132_089 /root]# ipcs<br />
&#8212;&#8212; Shared Memory Segments &#8212;&#8212;&#8211;<br />
key        shmid      owner      perms      bytes      nattch     status      <br />
0&#215;00000000 8552448    root      600        184324     74         dest          <br />
&#8212;&#8212; Semaphore Arrays &#8212;&#8212;&#8211;<br />
key        semid      owner      perms      nsems      <br />
0&#215;00000000 8486912    nobody    600        1          <br />
&#8212;&#8212; Message Queues &#8212;&#8212;&#8211;<br />
key        msqid      owner      perms      used-bytes   messages  </div>
</div>
<p>没有那么多了。</p></div>
<div>再重新启动apache，这次正常启动了</div>
<div>另外一个问题，就是日志是用中文输出的，对应的错误提示在网上无法搜到，而对应的英文</p>
<div>
<div style="font-size: 10pt; width: 98%; color: #000000; word-break: break-all; line-height: 16px; font-family: verdana,宋体; background-color: #eeeeee; border: #cccccc 1px solid; padding: 4px;">semget: 设备上没有空间<br />
semget: No space left on device</div>
</div>
</div>
<div>在google上很容易找到结果。看来以后要把服务器的默认语言设置为英文才行。</div>
<div> </div>
<div>
<div>
<div style="font-size: 10pt; width: 98%; color: #000000; word-break: break-all; line-height: 16px; font-family: verdana,宋体; background-color: #eeeeee; border: #cccccc 1px solid; padding: 4px;">#export LC_ALL=en_US<br />
#locale</div>
</div>
</div>
<div> </div>
<h3  class="related_post_title">无相关文章，以下随机显示</h3><ul class="related_post"><li>2009年01月6号 -- <a href="http://ourapache.com/archives/25" title="Apache服务器使用.htaccess实现图片防盗链方法教程">Apache服务器使用.htaccess实现图片防盗链方法教程</a></li><li>2009年01月22号 -- <a href="http://ourapache.com/archives/64" title="Apache连接数设置prefork">Apache连接数设置prefork</a></li><li>2009年08月13号 -- <a href="http://ourapache.com/archives/270" title="Apache配置之URL重写">Apache配置之URL重写</a></li><li>2009年02月18号 -- <a href="http://ourapache.com/archives/146" title="apache和tomcat集成的总结">apache和tomcat集成的总结</a></li><li>2009年02月10号 -- <a href="http://ourapache.com/archives/109" title="谈谈Apache的优化">谈谈Apache的优化</a></li><li>2010年03月9号 -- <a href="http://ourapache.com/archives/318" title="Apache2中俩种设置PHP的异同">Apache2中俩种设置PHP的异同</a></li><li>2009年02月6号 -- <a href="http://ourapache.com/archives/72" title="gzip 与 deflate">gzip 与 deflate</a></li><li>2008年12月27号 -- <a href="http://ourapache.com/archives/11" title="apxs &#8211; Apache 扩展工具">apxs &#8211; Apache 扩展工具</a></li><li>2008年12月27号 -- <a href="http://ourapache.com/archives/9" title="apache禁止使用IP访问的实现方法">apache禁止使用IP访问的实现方法</a></li><li>2009年02月25号 -- <a href="http://ourapache.com/archives/170" title="Apache 两种虚拟主机方式的区别">Apache 两种虚拟主机方式的区别</a></li></ul>
	标签：<a href="http://ourapache.com/archives/category/debug" title="Apache解错方案" rel="tag">Apache解错方案</a>, <a href="http://ourapache.com/archives/tag/startssl" title="startssl" rel="tag">startssl</a>, <a href="http://ourapache.com/archives/tag/%e4%bf%a1%e5%8f%b7%e9%87%8f" title="信号量" rel="tag">信号量</a><br />
]]></content:encoded>
			<wfw:commentRss>http://ourapache.com/archives/121/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>重大漏洞, 让Apache上传不安全-php.rar</title>
		<link>http://ourapache.com/archives/19</link>
		<comments>http://ourapache.com/archives/19#comments</comments>
		<pubDate>Mon, 05 Jan 2009 12:57:09 +0000</pubDate>
		<dc:creator>OurApache</dc:creator>
				<category><![CDATA[Apache解错方案]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[rar]]></category>

		<guid isPermaLink="false">http://www.ourapache.com/?p=19</guid>
		<description><![CDATA[一般的网站都会开放rar附件上传,并可能会保留原来文件名称,这从而可能导致一个很严重的问题,xxx.php.rar文件会被Apache当作php文件来执行, 造成极大的安全隐患 .]]></description>
			<content:encoded><![CDATA[<p>一般的网站都会开放rar附件上传,并可能会保留原来文件名称,这从而可能导致一个很严重的问题,xxx.<a href="http://ourapache.com/archives/tag/php" class="st_tag internal_tag" rel="tag" title="标签 php 下的日志">php</a>.rar文件会被Apache当作php文件来执行, 造成极大的安全隐患 .</p>
<p>如何测试? 将你的某个php程序文件后缀名修改成  xxx.php.<a href="http://ourapache.com/archives/tag/rar" class="st_tag internal_tag" rel="tag" title="标签 rar 下的日志">rar</a> , 这时测试一下, 还是按照PHP文件解析执行,Apache并不会认为这是一个rar文件, 这是为什么呢?</p>
<p>原来,每遇到一种后双重后缀名(如xxx.php.rar)的文件,Apache都会去conf/mime.types 文件中检查最后一个后缀, 如果最后一个后缀并没有在mime.types文件中定义, 则使用前一个后缀来解释 , 因为在默认情况下,rar并未在mime.types中定义, 故Apache会使用php后缀来解释文件, 这就是漏洞的原因所在.</p>
<p>由此类推,如果使用xxx.jsp.ppp.rar 则会认为是jsp文件, 如果修改成xxx.shtml.rar ,则会识别成shtml文件.</p>
<p>a.php.c.d.e.rar 也是会被当成PHP文件解释的!<br />
想想,不知道有多少网站存在这个问题?</p>
<p>那么针对网络管理员,如何杜绝这个隐患 ?<br />
1.修改mime.types文件,在最后面加一条:</p>
<div class="wp_syntax" style="padding-bottom: 0px;">
<div class="code">
<pre class="apache apache" style="font-family: monospace;">application/rar rar</pre>
</div>
</div>
<p>然后重新启动Apache,即可.</p>
<p>针对WEB管理员及WEB程序开发者,如何更安全?<br />
1.只允许上传指定后缀名的文件,当然,要禁止掉rar格式文件上传.(但这条往往行不通,一般的网站都需要上传rar文件)<br />
2.对上传后的文件进行强制重命名, 强制使用最后一个扩展名,如原始文件名为xxx.php.rar ,上传后强制重命名为 20080912.rar即可避免这个隐患.</p>
<p>早期版本的phpcms 2007, discuz, ecshop都存在这个漏洞,  或许你的网站被挂马,就是因此引起.</p>
<p> </p>
<p> </p>
<p><strong>上面的文章是转的，我测试了一下,还真这样,不过修改mime.types是没有用的.</strong></p>
<p><strong>需要在http.conf中加入下面这些内容</strong></p>
<div class="wp_syntax" style="padding-bottom: 0px;">
<div class="code">
<pre class="apache apache" style="font-family: monospace;"><span style="color: #00007f;"><span style="font-family: Tahoma;">AddType</span></span> application/rar .rar
<span style="color: #00007f;"><span style="font-family: Tahoma;">AddType</span></span> application/x-compressed .rar
<span style="color: #00007f;"><span style="font-family: Tahoma;">AddType</span></span> application/x-rar .rar
<span style="color: #00007f;"><span style="font-family: Tahoma;">AddType</span></span> application/x-rar-compressed .rar
<span style="color: #00007f;"><span style="font-family: Tahoma;">AddType</span></span> application/x-rar-compressed; application/x-compressed .rar
<span style="color: #00007f;"><span style="font-family: Tahoma;">AddType</span></span> compressed/rar; application/x-rar-compressed .rar</pre>
</div>
</div>
<p> </p>
<p><strong>这样就不会出问题了，测试过了，加我上面这些是没有问题的。</strong></p>
<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li>2009年08月13号 -- <a href="http://ourapache.com/archives/286" title="linux下查看nginx，apache，mysql，php的编译参数">linux下查看nginx，apache，mysql，php的编译参数</a></li><li>2009年01月6号 -- <a href="http://ourapache.com/archives/27" title="php+mysql+apache编码深度解析">php+mysql+apache编码深度解析</a></li></ul>
	标签：<a href="http://ourapache.com/archives/category/debug" title="Apache解错方案" rel="tag">Apache解错方案</a>, <a href="http://ourapache.com/archives/tag/php" title="php" rel="tag">php</a>, <a href="http://ourapache.com/archives/tag/rar" title="rar" rel="tag">rar</a><br />
]]></content:encoded>
			<wfw:commentRss>http://ourapache.com/archives/19/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

