<?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>鬼の领地 &#187; Apache</title>
	<atom:link href="http://blog.upsuper.org/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.upsuper.org</link>
	<description>the place where there are some ghost appearing...</description>
	<lastBuildDate>Thu, 17 Jun 2010 08:12:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Apache 的 Rewrite 模块 Bug 一则</title>
		<link>http://blog.upsuper.org/a-bug-of-rewrite-module-in-apache/</link>
		<comments>http://blog.upsuper.org/a-bug-of-rewrite-module-in-apache/#comments</comments>
		<pubDate>Sun, 07 Mar 2010 11:20:54 +0000</pubDate>
		<dc:creator>upsuper</dc:creator>
				<category><![CDATA[探究学习]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Bug]]></category>
		<category><![CDATA[Rewrite]]></category>

		<guid isPermaLink="false">http://blog.upsuper.org/?p=1086</guid>
		<description><![CDATA[我发觉研究的东西多了，就会看到各种神奇的 Bug……
今天写的这个 Bug 是关于 Apache 的 Rewrite 模块的。先来看一个很正常的 Rewrite 规则：

1
2
RewriteCond %{REQUEST_URI} \.u$
RewriteRule ^(.*)\.u$ $1

这个什么意思呢？用过的人一定看得出来，就是把一个 .t 结尾的请求发送到一个去掉 .t 的文件上面。比如我如果请求 upsuper.u 就会自动调用 upsuper 这个文件来返回。这没有什么疑问。
然后，我们发现，.u 文件浏览器不知道是什么，而 upsuper 这个文件在服务器上又是没有类型的，于是 Apache 不知道告诉浏览器（或者错误地告诉了一个）MIME-Type。这样即使这个文件是个网页，浏览器上也会出现下载提示或者当作纯文本直接输出。
翻阅了一下 Rewrite 模块的资料，我们了解到可以使用 T 这个标志符来强制指定 MIME-Type 类型，于是规则变成了下面这样：

1
2
RewriteCond %{REQUEST_URI} \.u$
RewriteRule ^(.*)\.u$ $1 [T=text/html]

可是无效！
Bug 开始出现了~

在 Apache 基金会的 Bugzilla 里面翻到了关于这个 Bug 的内容。然后看一看日期，OMG，2005年的 Bug，很跨10个年头没有解决！
看了一下，里面有一个可能是开发人员，说这一问题可能是由于引发了一个内部跳转导致的。并且提供了一种解决方法，我参照该解决方法再次修改我的 Rewrite 规则，变成下面这样：

1
2
3
RewriteCond %{REQUEST_URI} \.u$
RewriteRule ^(.*)\.u$ $1
RewriteRule . - [T=text/html]

成功了！泪流满面……
不过，有趣的还没结束~仅能变出 [...]]]></description>
			<content:encoded><![CDATA[<p>我发觉研究的东西多了，就会看到各种神奇的 Bug……</p>
<p>今天写的这个 Bug 是关于 Apache 的 Rewrite 模块的。先来看一个很正常的 Rewrite 规则：</p>

<div class="wp_codebox"><table><tr id="p10866"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p1086code6"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">RewriteCond</span> %{REQUEST_URI} \.u$
<span style="color: #00007f;">RewriteRule</span> ^(.*)\.u$ $<span style="color: #ff0000;">1</span></pre></td></tr></table></div>

<p>这个什么意思呢？用过的人一定看得出来，就是把一个 .t 结尾的请求发送到一个去掉 .t 的文件上面。比如我如果请求 upsuper.u 就会自动调用 upsuper 这个文件来返回。这没有什么疑问。</p>
<p>然后，我们发现，.u 文件浏览器不知道是什么，而 upsuper 这个文件在服务器上又是没有类型的，于是 Apache 不知道告诉浏览器（或者错误地告诉了一个）MIME-Type。这样即使这个文件是个网页，浏览器上也会出现下载提示或者当作纯文本直接输出。</p>
<p>翻阅了一下 <a href="http://httpd.apache.org/docs/2.2/rewrite/">Rewrite 模块的资料</a>，我们了解到可以使用 T 这个标志符来强制指定 MIME-Type 类型，于是规则变成了下面这样：</p>

<div class="wp_codebox"><table><tr id="p10867"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p1086code7"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">RewriteCond</span> %{REQUEST_URI} \.u$
<span style="color: #00007f;">RewriteRule</span> ^(.*)\.u$ $<span style="color: #ff0000;">1</span> [T=text/html]</pre></td></tr></table></div>

<p>可是无效！</p>
<p>Bug 开始出现了~<br />
<span id="more-1086"></span><br />
在 Apache 基金会的 Bugzilla 里面翻到了<a href="https://issues.apache.org/bugzilla/show_bug.cgi?id=36590">关于这个 Bug 的内容</a>。然后看一看日期，OMG，2005年的 Bug，很跨10个年头没有解决！</p>
<p>看了一下，里面有一个可能是开发人员，说这一问题可能是由于引发了一个内部跳转导致的。并且提供了一种解决方法，我参照该解决方法再次修改我的 Rewrite 规则，变成下面这样：</p>

<div class="wp_codebox"><table><tr id="p10868"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p1086code8"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">RewriteCond</span> %{REQUEST_URI} \.u$
<span style="color: #00007f;">RewriteRule</span> ^(.*)\.u$ $<span style="color: #ff0000;">1</span>
<span style="color: #00007f;">RewriteRule</span> . - [T=text/html]</pre></td></tr></table></div>

<p>成功了！泪流满面……</p>
<p>不过，有趣的还没结束~仅能变出 MIME-Type 为 text/html 本来就不是我最初的想法。我的想法更大胆一些：识别 URL 中的一部分作为 MIME-Type！</p>
<p>我发现 Rewrite 规则中，标志 E 可以修改环境变量，而且在后面的过程中还可以使用~我觉得那这个来当中间变量是一个很好的想法，于是就动手了：</p>

<div class="wp_codebox"><table><tr id="p10869"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p1086code9"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">RewriteCond</span> %{REQUEST_URI} \.u$
<span style="color: #00007f;">RewriteRule</span> ^([a-zA-Z]+/[a-zA-Z-]+)/(.*)\.u$ $<span style="color: #ff0000;">2</span> [E=MIMETYPE:$<span style="color: #ff0000;">1</span>]
<span style="color: #00007f;">RewriteRule</span> . - [T=%{ENV:MIMETYPE}]</pre></td></tr></table></div>

<p>稍加辨别不难看出，“([a-zA-Z]+/[a-zA-Z-]+)”部分正是识别一个 MIME-Type，在而后的 [E=MIMETYPE:$1] 将这一部分存入了 MIMETYPE 这一环境变量，然后在第三行将这个环境变量的值作为 MIME-Type。</p>
<p>可是，当我们尝试访问 text/html/upsuper.u 的时候，这个文件再次被直接输出了，MIME-Type 根本没有被指定！疯了……</p>
<p>看看 RewriteLog 里面都写了些什么（已去除无关部分）：</p>

<div class="wp_codebox"><table><tr id="p108610"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code" id="p1086code10"><pre class="text" style="font-family:monospace;">[rid#21e031f8/initial] (3) add path info postfix: ~/web/test/text -&gt; ~/web/test/text/html/upsuper.u
[rid#21e031f8/initial] (3) strip per-dir prefix: ~/web/test/text/html/upsuper.u -&gt; text/html/upsuper.u
[rid#21e031f8/initial] (3) applying pattern '^([a-zA-Z]+/[a-zA-Z-]+)/(.*)\.u$' to uri 'text/html/upsuper.u'
[rid#21e031f8/initial] (2) rewrite 'text/html/upsuper.u' -&gt; 'upsuper'
[rid#21e031f8/initial] (3) add per-dir prefix: upsuper -&gt; ~/web/test/upsuper
[rid#21e031f8/initial] (3) add path info postfix: ~/web/test/upsuper -&gt; ~/web/test/upsuper/html/upsuper.u
[rid#21e031f8/initial] (3) strip per-dir prefix: ~/web/test/upsuper/html/upsuper.u -&gt; upsuper/html/upsuper.u
[rid#21e031f8/initial] (3) applying pattern '.' to uri 'upsuper/html/upsuper.u'
[rid#21e031f8/initial] (2) remember ~/web/test/upsuper to have MIME-type 'text/html'
[rid#21e031f8/initial] (2) strip document_root prefix: ~/web/test/upsuper -&gt; /test/upsuper
[rid#21e031f8/initial] (1) internal redirect with /test/upsuper [INTERNAL REDIRECT]
[rid#21e031f8/initial] (1) force filename redirect:/test/upsuper to have MIME-type 'text/html'
[rid#21e08c80/initial/redir#1] (3) strip per-dir prefix: ~/web/test/upsuper -&gt; upsuper
[rid#21e08c80/initial/redir#1] (3) applying pattern '^([a-zA-Z]+/[a-zA-Z-]+)/(.*)\.u$' to uri 'upsuper'
[rid#21e08c80/initial/redir#1] (3) strip per-dir prefix: ~/web/test/upsuper -&gt; upsuper
[rid#21e08c80/initial/redir#1] (3) applying pattern '.' to uri 'upsuper'
[rid#21e08c80/initial/redir#1] (1) pass through ~/web/test/upsuper</pre></td></tr></table></div>

<p>注意看第9行，在这里 MIME-Type 已经被正确地设置了，但随后开始了内部重定向……orz</p>
<p>本质上说，最后这样修改和前面一次没有很大的本质不同，最后一句都是除了修改 MIME-Type 没有修改任何网址内容。可是表现却有如此大的不同，究竟是为什么呢？</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.upsuper.org/a-bug-of-rewrite-module-in-apache/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>新空间</title>
		<link>http://blog.upsuper.org/my-new-web-space/</link>
		<comments>http://blog.upsuper.org/my-new-web-space/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 15:11:20 +0000</pubDate>
		<dc:creator>upsuper</dc:creator>
				<category><![CDATA[探究学习]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[CGI]]></category>
		<category><![CDATA[My Blog]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[和谐]]></category>

		<guid isPermaLink="false">http://blog.upsuper.org/?p=1069</guid>
		<description><![CDATA[由于某些众所周知的原因，我准备将空间搬到米国去了。由于另一个众所周知的原因，现在的域名也将很快停止使用。
我已经申请好了新的空间，近期可能就要搬过去了。先做个广告：在此诚招空间合租者一位，无限空间无限流量，PHP、Python、Perl、RoR、CGI、CGI-BIN、MySQL、PgSQL 全功能 Linux 空间，可自定义 php.ini，提供域名对应的邮箱储存、邮箱别名服务，支持 POP3、IMAP、邮件列表，独立 FTP 管理，带免费自签名证书的 SSL 服务，含一个免费域名及一个独立 IP，3年共计525元RMB。有意者邮箱联系 quanxunzhen@gmail.com
不过因为新空间还没摸索清楚，还在研究搬迁事宜。

下面讲讲今天的探索……这个新空间的 PHP 用了 CGI 的模式，而不是传统（或者说我熟悉的）PHP Module 的模式，而且作为 CGI 的 php 解析程序和 php.ini 配置文件也是放在网站的 cgi-bin 目录里面的，因此我怀疑可玩性很高，甚至可以自己编译 PHP 放上去用。不过这个空间有一个很麻烦的，就是不支持自动的泛域名匹配，这大大的不如现在的这个空间方便。不过经过一番研究，也并不是没有办法的。今天才算是第一次体会到了 Apache mod_rewrite 的强大！
本来以为 rewrite 不能实现那样功能的，因为似乎 rewrite 不能把主机名弄进来匹配，结果发现我想错了。参考了一些 Apache 的官方资料，我发现 Apache 的官方文档里有一种很有趣的方式间接实现泛域名到子文件夹的匹配，大约是这个样子的：

1
2
3
4
RewriteEngine on
RewriteCond   %{HTTP_HOST}             [...]]]></description>
			<content:encoded><![CDATA[<p>由于某些众所周知的原因，我准备将空间搬到米国去了。由于另一个众所周知的原因，现在的域名也将很快停止使用。</p>
<p>我已经申请好了新的空间，近期可能就要搬过去了。先做个广告：<strong>在此诚招空间合租者一位，无限空间无限流量，PHP、Python、Perl、RoR、CGI、CGI-BIN、MySQL、PgSQL 全功能 Linux 空间，可自定义 php.ini，提供域名对应的邮箱储存、邮箱别名服务，支持 POP3、IMAP、邮件列表，独立 FTP 管理，带免费自签名证书的 SSL 服务，含一个免费域名及一个独立 IP，3年共计525元RMB。有意者邮箱联系 <a href="mailto:quanxunzhen@gmail.com">quanxunzhen@gmail.com</a></strong></p>
<p>不过因为新空间还没摸索清楚，还在研究搬迁事宜。<br />
<span id="more-1069"></span><br />
下面讲讲今天的探索……这个新空间的 PHP 用了 CGI 的模式，而不是传统（或者说我熟悉的）PHP Module 的模式，而且作为 CGI 的 php 解析程序和 php.ini 配置文件也是放在网站的 cgi-bin 目录里面的，因此我怀疑可玩性很高，甚至可以自己编译 PHP 放上去用。不过这个空间有一个很麻烦的，就是不支持自动的泛域名匹配，这大大的不如现在的这个空间方便。不过经过一番研究，也并不是没有办法的。今天才算是第一次体会到了 Apache mod_rewrite 的强大！</p>
<p>本来以为 rewrite 不能实现那样功能的，因为似乎 rewrite 不能把主机名弄进来匹配，结果发现我想错了。参考了一些 Apache 的官方资料，我发现 Apache 的官方文档里有一种很有趣的方式间接实现泛域名到子文件夹的匹配，大约是这个样子的：</p>

<div class="wp_codebox"><table><tr id="p106915"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p1069code15"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">RewriteEngine</span> <span style="color: #0000ff;">on</span>
<span style="color: #00007f;">RewriteCond</span>   %{HTTP_HOST}                 ^www\.[^.]+\.host\.com$
<span style="color: #00007f;">RewriteRule</span>   ^(.+)                        %{HTTP_HOST}$<span style="color: #ff0000;">1</span>          [C]
<span style="color: #00007f;">RewriteRule</span>   ^www\.([^.]+)\.host\.com(.*) /home/$<span style="color: #ff0000;">1</span>$<span style="color: #ff0000;">2</span></pre></td></tr></table></div>

<p>惊叹于这种其实妙想！这个恐怕能实现的功能比那个 VirtualHost 的模块还要强大了吧~</p>
<p>不过这个代码似乎是不能用的囧……做一个适合的修改就发生 500 错误……经过思考，我想起了很早以前说过的，mod_rewrite 是会把修改过的网址再次注入 rewrite 的，因此如果这样那么这个网址可能会不断的经过这个 rewrite 过程，造成死循环，最后被 Apache 以 500 强制结束。</p>
<p>看来想在网站根目录下像现在这样搞是不行了……不过，办法总是有的，其实有的时候我觉得自己还是蛮聪明的~我就在根目录下建立了一个名叫 www 的文件夹，然后给出了下面这样的 .htaccess：</p>

<div class="wp_codebox"><table><tr id="p106916"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p1069code16"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">RewriteEngine</span> <span style="color: #0000ff;">On</span>
<span style="color: #00007f;">RewriteCond</span> %{HTTP_HOST} ^[^\.]+\.upsuper\.org\.cn$
<span style="color: #00007f;">RewriteCond</span> %{REQUEST_URI} !^/www/
<span style="color: #00007f;">RewriteRule</span> ^(.*)$ %{HTTP_HOST}/$<span style="color: #ff0000;">1</span>
<span style="color: #00007f;">RewriteRule</span> ^([^\.]+)\.upsuper\.org\.cn/(.*)$ /www/$<span style="color: #ff0000;">1</span>/$<span style="color: #ff0000;">2</span></pre></td></tr></table></div>

<p>OK，现在已经非常正常了，网页可以正常访问了~不过新的问题再度出现！所有的 PHP 都显示 404 错误……我汗！404？！那个 PHP 明明在那里凭啥 404 呢？</p>
<p>后来在空间商的 FAQ 里面偶然看到，解析 PHP 用的东西储存在已经被我删掉的 cgi-bin 文件夹里面……呃……马上把所有内容删掉恢复原来的内容。然后再放上这个，还是 404……其中必有问题……那么问题一定出在 cgi-bin 文件夹上……难道 Apache 最后也要通过自己访问 CGI 接口？其实其中奥妙我也不是很了解，不过最后又加了一条针对 cgi-bin 的 rewrite 规则，成功解决。关于 Apache 和 PHP 通过 CGI 接口的机制看来还是很值得好好研究研究的嗯……下面是最后的代码：</p>

<div class="wp_codebox"><table><tr id="p106917"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p1069code17"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">RewriteEngine</span> <span style="color: #0000ff;">On</span>
<span style="color: #00007f;">RewriteCond</span> %{HTTP_HOST} ^[^\.]+\.upsuper\.org\.cn$
<span style="color: #00007f;">RewriteCond</span> %{REQUEST_URI} !^/www/
<span style="color: #00007f;">RewriteCond</span> %{REQUEST_URI} !^/cgi-bin/
<span style="color: #00007f;">RewriteRule</span> ^(.*)$ %{HTTP_HOST}/$<span style="color: #ff0000;">1</span>
<span style="color: #00007f;">RewriteRule</span> ^([^\.]+)\.upsuper\.org\.cn/(.*)$ /www/$<span style="color: #ff0000;">1</span>/$<span style="color: #ff0000;">2</span></pre></td></tr></table></div>

<p>最后还有一个小小的问题，就是遇到找不到的 PHP，服务器虽然返回了 404 的头，不过显示的内容却是“No input file specified.”，而不是我指定的 404 页面（当然，IE 用户肯定什么都看不到，因为 IE 已经默认为他们准备好了一个“友好”的 404 页面）。这个虽然不是什么大问题，不过也还是很烦人的，有搜索了一番，最后在 rewrite 规则里面又加了两行解决问题：</p>

<div class="wp_codebox"><table><tr id="p106918"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p1069code18"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">RewriteCond</span> %{DOCUMENT_ROOT}/$<span style="color: #ff0000;">1</span> !-f
<span style="color: #00007f;">RewriteRule</span> ^(.*\.php)$ - [T=text/html]</pre></td></tr></table></div>

<p>稍微想一想肯定看出来，这个代码不是没有问题的，不过我想我应该不会遇到吧……嗯……</p>
<p>最后就是关于 php.ini，php.ini 里面不小心撇到了 mbstring 的设置，发现默认语言竟然是 Japanese……呃……马上改成了 Chinese，并且把下面的默认编码 EUC-JP 也改成了 EUC-CN，真是无语……不知道这个是 PHP 的默认配置，还是那个客服看我英语这么差以为我是日本人“帮”我设置的呢？</p>
<p>参考资料：</p>
<ul>
<li><a href="http://httpd.apache.org/docs/2.2/rewrite/rewrite_guide.html">URL Rewriting Guide &#8211; Apache HTTP Server</a></li>
<li><a href="http://jenseng.com/archives/000035.html">&#8220;No input file specified&#8221; | jenseng.com</a> <a href="http://www.panuworld.net/">panuworld</a> 的回复</li>
</ul>
<p>还想讲一点买空间的事情。因为这个空间商支持支付宝，我就决定用支付宝。而且支付宝不是支持 Linux 么，很好的嘛。今天中午就跑到邮局去汇款给我很早以前申请了但一直没用的支付宝账户充钱。然后充完跑回来打开上网本登录支付宝充值……为什么要打开上网本？因为台机的 Arch Linux 已经把 Firefox 升级到了 3.6，而支付宝唯一支持 Linux 的插件，是不兼容 Firefox 3.6 的……幸好上网本的 Ubuntu 9.10 很乖巧的使用了 Firefox 3.5.8，还能用那个支付宝插件。很期待支付宝能快些支持 Firefox 3.6，这样我以后也可以网购了~这年头天朝的银行不厚道，几乎完全不支持我家 Linux……还是支付宝好嗯~</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.upsuper.org/my-new-web-space/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Ubuntu之旅（二）</title>
		<link>http://blog.upsuper.org/ubuntu-trip-2/</link>
		<comments>http://blog.upsuper.org/ubuntu-trip-2/#comments</comments>
		<pubDate>Sun, 11 May 2008 10:49:49 +0000</pubDate>
		<dc:creator>upsuper</dc:creator>
				<category><![CDATA[探究学习]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[虚拟机]]></category>

		<guid isPermaLink="false">http://blog.upsuper.org/?p=88</guid>
		<description><![CDATA[今天继续Ubuntu之旅~
今天做的主要事情就是安装IE。安装IE其实没什么特别好讲的，为什么呢？因为已经有现成的脚本了，直接下载过来然后运行一下就可以了。具体就是要下载一个文件ies4linux.tar.gz，这是最重要的东西了，其他都简单。不过这个文件我今天在Ubuntu上死都下不了，从迅雷下载的情况看，是没有从原始地址得到数据，所以传到这里来，大家需要的可以直接下：ies4linux.tar.gz (324.55KB)。

下面就是安装了：

1
2
3
4
5
6
sudo apt-get install cabextract wine	#安装wine
#这是从我的网站下载这个文件，如果下好就不用再下了
wget http://down.upsuper.org/ies4linux.tar.gz
tar zxvf ies4linux.tar.gz	#解压文件
cd ies4linux-*	#切换到解压的目录
./ies4linux	#运行安装程序

这个安装程序还是比较智能化的。记得我曾经尝试过用

1
sudo ./ies4linux

结果提示我，建议我不要使用root来运行IE。
当然，这个安装过程要到微软的网站下载相关程序，所以需要一些等待。而且不要以为等待就可以到处乱跑，因为那个程序似乎写得比较粗，一会儿一会儿会出点小错，好在支持断点继续。不过这导致我运行了9次这个安装程序，才成功地装上IE。另外，注意两点，一是一开始那个窗口里面，记得选择“CN”作为语言，安装完就是中文的；二是下面那个按转Adobe Flash插件的勾建议是去掉，因为今天下载Flash插件的时候等了半天都没反应……
不过今天在安装的过程中还是有许多小小的插曲~因为我一开始是想安装IE7的，所以预先在宿主Windows下把IE7的安装文件下好了，这个IE7的安装文件就是我们在Windows下安装用的，可以到这里下载：http://www.google.com/toolbar/ie7/。不过后来没什么办法把它传到虚拟机里，所以就在虚拟机又下了一遍。这里推荐一个软件叫做d4x，可以用apt安装：

1
sudo apt-get install d4x

安装好后就直接在终端中输入d4x就运行了。在那里面下载速度还是可以的，不过没有像迅雷这样能够下源地址下不到的东西……
还有要说的就是为了能够把文件传进来所做的事情。我先是安装了samba服务，配置了半天，Ubuntu不能访问Windows的共享目录，Windows也不能访问Ubuntu的共享目录……最后还逼我把宿主的Apache打开，让虚拟机访问。
今天因为要来学校的缘故，没有把IE7装好。不过前人都有不少经验了，要装也是很容易的吧。
走之前还试了一下我们pidgin。发现其支持的协议真多，其中包括了我常用的MSN和Google Talk，不过也包含了令人厌恶的QQ。另外有个人推荐我用psi，我就试装了一下。不过实在是觉得没什么意义，还占用38MB的空间，装完就直接卸掉了。顺便说，开始的时候我只卸载psi，然后apt提示我，只会少掉6MB。再看看上面的提示，apt告诉我可以用autoremove来连带卸载没用的东西：

1
2
sudo apt-get install psi
sudo apt-get autoremove psi

还真是强大！想想Windows哪有这么好……
我觉得我很快就能够转入Ubuntu了。现在的它对于我来说已经相当方便了哈~
]]></description>
			<content:encoded><![CDATA[<p>今天继续Ubuntu之旅~</p>
<p>今天做的主要事情就是安装IE。安装IE其实没什么特别好讲的，为什么呢？因为已经有现成的脚本了，直接下载过来然后运行一下就可以了。具体就是要下载一个文件ies4linux.tar.gz，这是最重要的东西了，其他都简单。不过这个文件我今天在Ubuntu上死都下不了，从迅雷下载的情况看，是没有从原始地址得到数据，所以传到这里来，大家需要的可以直接下：<a href="http://down.upsuper.org/ies4linux.tar.gz">ies4linux.tar.gz</a> (324.55KB)。</p>
<p><span id="more-88"></span></p>
<p>下面就是安装了：</p>

<div class="wp_codebox"><table><tr id="p8823"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p88code23"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> cabextract wine	<span style="color: #666666; font-style: italic;">#安装wine</span>
<span style="color: #666666; font-style: italic;">#这是从我的网站下载这个文件，如果下好就不用再下了</span>
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>down.upsuper.org<span style="color: #000000; font-weight: bold;">/</span>ies4linux.tar.gz
<span style="color: #c20cb9; font-weight: bold;">tar</span> zxvf ies4linux.tar.gz	<span style="color: #666666; font-style: italic;">#解压文件</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> ies4linux-<span style="color: #000000; font-weight: bold;">*</span>	<span style="color: #666666; font-style: italic;">#切换到解压的目录</span>
.<span style="color: #000000; font-weight: bold;">/</span>ies4linux	<span style="color: #666666; font-style: italic;">#运行安装程序</span></pre></td></tr></table></div>

<p>这个安装程序还是比较智能化的。记得我曾经尝试过用</p>

<div class="wp_codebox"><table><tr id="p8824"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p88code24"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> .<span style="color: #000000; font-weight: bold;">/</span>ies4linux</pre></td></tr></table></div>

<p>结果提示我，建议我不要使用root来运行IE。</p>
<p>当然，这个安装过程要到微软的网站下载相关程序，所以需要一些等待。而且不要以为等待就可以到处乱跑，因为那个程序似乎写得比较粗，一会儿一会儿会出点小错，好在支持断点继续。不过这导致我运行了9次这个安装程序，才成功地装上IE。另外，注意两点，一是一开始那个窗口里面，记得选择“CN”作为语言，安装完就是中文的；二是下面那个按转Adobe Flash插件的勾建议是去掉，因为今天下载Flash插件的时候等了半天都没反应……</p>
<p>不过今天在安装的过程中还是有许多小小的插曲~因为我一开始是想安装IE7的，所以预先在宿主Windows下把IE7的安装文件下好了，这个IE7的安装文件就是我们在Windows下安装用的，可以到这里下载：<a href="http://www.google.com/toolbar/ie7/" target="_blank">http://www.google.com/toolbar/ie7/</a>。不过后来没什么办法把它传到虚拟机里，所以就在虚拟机又下了一遍。这里推荐一个软件叫做d4x，可以用apt安装：</p>

<div class="wp_codebox"><table><tr id="p8825"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p88code25"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> d4x</pre></td></tr></table></div>

<p>安装好后就直接在终端中输入d4x就运行了。在那里面下载速度还是可以的，不过没有像迅雷这样能够下源地址下不到的东西……</p>
<p>还有要说的就是为了能够把文件传进来所做的事情。我先是安装了samba服务，配置了半天，Ubuntu不能访问Windows的共享目录，Windows也不能访问Ubuntu的共享目录……最后还逼我把宿主的Apache打开，让虚拟机访问。</p>
<p>今天因为要来学校的缘故，没有把IE7装好。不过前人都有不少经验了，要装也是很容易的吧。</p>
<p>走之前还试了一下我们pidgin。发现其支持的协议真多，其中包括了我常用的MSN和Google Talk，不过也包含了令人厌恶的QQ。另外有个人推荐我用psi，我就试装了一下。不过实在是觉得没什么意义，还占用38MB的空间，装完就直接卸掉了。顺便说，开始的时候我只卸载psi，然后apt提示我，只会少掉6MB。再看看上面的提示，apt告诉我可以用autoremove来连带卸载没用的东西：</p>

<div class="wp_codebox"><table><tr id="p8826"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p88code26"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> psi
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> autoremove psi</pre></td></tr></table></div>

<p>还真是强大！想想Windows哪有这么好……</p>
<p>我觉得我很快就能够转入Ubuntu了。现在的它对于我来说已经相当方便了哈~</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.upsuper.org/ubuntu-trip-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu之旅（一）</title>
		<link>http://blog.upsuper.org/ubuntu-trip-1/</link>
		<comments>http://blog.upsuper.org/ubuntu-trip-1/#comments</comments>
		<pubDate>Sat, 10 May 2008 15:44:10 +0000</pubDate>
		<dc:creator>upsuper</dc:creator>
				<category><![CDATA[探究学习]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[快捷键]]></category>
		<category><![CDATA[虚拟机]]></category>

		<guid isPermaLink="false">http://blog.upsuper.org/?p=87</guid>
		<description><![CDATA[今天小小地探索了一下伟大的Ubuntu，使用的是刚出的Ubuntu8.04LTS。这里就来说一说吧~

本来想给我的电脑直接装上Ubuntu8.04LTS的，盘刻好了，还用分区魔术师划了些地方出来装。结果还是失败了，好像是提示什么I/O APIC的问题，Ubuntu的Linux内核根本启动不起来……所以最后只好回到Windows下用VMware了。
原来我的VMware里面就有一个Ubuntu的虚拟机，今天便把原来的内容全部消掉，重新安装了一个新的Ubuntu。安装还算顺利，就是安完还是半中文半英文，看得蛮不爽的说。
我的VMware设置为桥接到宿主所在网络，所以和在真实的网络环境一样。因为知道Ubuntu最依靠的就是网络，所以就先把网络设置好了。我家使用的是一个小型的支持DHCP的家用路由器，因此我在“系统-&#62;系统管理-&#62;网络”里面点击解锁后点击列表中的第一个，并设置其为DHCP。随后登入路由器，发现为我的Ubuntu虚拟系统分配了一个新的IP地址。Ubuntu的网络是连上了，可是我宿主机Windows的网络却不能用了，可虚拟机里面却好好的……郁闷……算了，先用虚拟机吧~
下面来处理语言的问题。经过调查，我先更新了apt的sources.list。首先点击“应用程序-&#62;附件-&#62;终端”，应用程序可能是中文，不过反正就是第一个菜单。然后输入：

1
2
sudo cp /etc/apt/sources.list /etc/apt/sources.list_backup
sudo gedit /etc/apt/sources.list

前面的sudo大约表示能够用最大权限，似乎etc目录都要用最大权限才能修改的样子，至于gedit是使用Gnome的Ubuntu下才有的命令。接下来我跟大家说说我更新以后的sources.list吧：

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
deb http://archive.ubuntu.org.cn/ubuntu-cn/ hardy main restricted universe multiverse
&#160;
# 这一套极快，每秒可以上MB级
deb http://ubuntu.cn99.com/ubuntu/ hardy main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ hardy-security main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ hardy-updates main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ hardy-proposed main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ hardy-backports main restricted universe multiverse
deb-src http://ubuntu.cn99.com/ubuntu/ hardy main restricted universe multiverse
deb-src http://ubuntu.cn99.com/ubuntu/ hardy-security main restricted universe [...]]]></description>
			<content:encoded><![CDATA[<p>今天小小地探索了一下伟大的Ubuntu，使用的是刚出的Ubuntu8.04LTS。这里就来说一说吧~</p>
<p><span id="more-87"></span></p>
<p>本来想给我的电脑直接装上Ubuntu8.04LTS的，盘刻好了，还用分区魔术师划了些地方出来装。结果还是失败了，好像是提示什么I/O APIC的问题，Ubuntu的Linux内核根本启动不起来……所以最后只好回到Windows下用VMware了。</p>
<p>原来我的VMware里面就有一个Ubuntu的虚拟机，今天便把原来的内容全部消掉，重新安装了一个新的Ubuntu。安装还算顺利，就是安完还是半中文半英文，看得蛮不爽的说。</p>
<p>我的VMware设置为桥接到宿主所在网络，所以和在真实的网络环境一样。因为知道Ubuntu最依靠的就是网络，所以就先把网络设置好了。我家使用的是一个小型的支持DHCP的家用路由器，因此我在“系统-&gt;系统管理-&gt;网络”里面点击解锁后点击列表中的第一个，并设置其为DHCP。随后登入路由器，发现为我的Ubuntu虚拟系统分配了一个新的IP地址。Ubuntu的网络是连上了，可是我宿主机Windows的网络却不能用了，可虚拟机里面却好好的……郁闷……算了，先用虚拟机吧~</p>
<p>下面来处理语言的问题。经过调查，我先更新了apt的sources.list。首先点击“应用程序-&gt;附件-&gt;终端”，应用程序可能是中文，不过反正就是第一个菜单。然后输入：</p>

<div class="wp_codebox"><table><tr id="p8734"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p87code34"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apt<span style="color: #000000; font-weight: bold;">/</span>sources.list <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apt<span style="color: #000000; font-weight: bold;">/</span>sources.list_backup
<span style="color: #c20cb9; font-weight: bold;">sudo</span> gedit <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apt<span style="color: #000000; font-weight: bold;">/</span>sources.list</pre></td></tr></table></div>

<p>前面的sudo大约表示能够用最大权限，似乎etc目录都要用最大权限才能修改的样子，至于gedit是使用Gnome的Ubuntu下才有的命令。接下来我跟大家说说我更新以后的sources.list吧：</p>

<div class="wp_codebox"><table><tr id="p8735"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
</pre></td><td class="code" id="p87code35"><pre class="text" style="font-family:monospace;">deb http://archive.ubuntu.org.cn/ubuntu-cn/ hardy main restricted universe multiverse
&nbsp;
# 这一套极快，每秒可以上MB级
deb http://ubuntu.cn99.com/ubuntu/ hardy main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ hardy-security main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ hardy-updates main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ hardy-proposed main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ hardy-backports main restricted universe multiverse
deb-src http://ubuntu.cn99.com/ubuntu/ hardy main restricted universe multiverse
deb-src http://ubuntu.cn99.com/ubuntu/ hardy-security main restricted universe multiverse
deb-src http://ubuntu.cn99.com/ubuntu/ hardy-updates main restricted universe multiverse
deb-src http://ubuntu.cn99.com/ubuntu/ hardy-proposed main restricted universe multiverse
deb-src http://ubuntu.cn99.com/ubuntu/ hardy-backports main restricted universe multiverse
&nbsp;
deb http://mirror.rootguide.org/ubuntu/ hardy main restricted universe multiverse
deb-src http://mirror.rootguide.org/ubuntu/ hardy main restricted universe multiverse
deb http://mirror.rootguide.org/ubuntu/ hardy-updates main restricted universe multiverse
deb-src http://mirror.rootguide.org/ubuntu/ hardy-updates main restricted universe multiverse
deb http://mirror.rootguide.org/ubuntu/ hardy-backports main restricted universe multiverse
deb-src http://mirror.rootguide.org/ubuntu/ hardy-backports main restricted universe multiverse
deb http://mirror.rootguide.org/ubuntu/ hardy-security main restricted universe multiverse
deb-src http://mirror.rootguide.org/ubuntu/ hardy-security main restricted universe multiverse
deb http://mirror.rootguide.org/ubuntu/ hardy-proposed main multiverse restricted universe
deb-src http://mirror.rootguide.org/ubuntu/ hardy-proposed main restricted universe multiverse
&nbsp;
# 这是官方的源
deb http://archive.ubuntu.com/ubuntu/ hardy main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ hardy-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ hardy-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ hardy-proposed main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ hardy-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ hardy main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ hardy-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ hardy-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ hardy-proposed main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ hardy-backports main restricted universe multiverse</pre></td></tr></table></div>

<p>接着就在终端中运行</p>

<div class="wp_codebox"><table><tr id="p8736"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p87code36"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> update</pre></td></tr></table></div>

<p>一阵等待过后（等待的时候玩Ubuntu里面的数独，发觉还是有些难度的），然后打开“系统-&gt;系统设置-&gt;语言设置”里面，找到中文打上钩，确定以后就自动完成了中文语言包的下载，重新启动后就看到了全中文的界面！然后使用Firefox上网，可以用Ctrl+Space调出中文的输入法。个人觉得里面默认的拼音输入法不亚于搜狗哈~</p>
<p>接着就觉得看过去太小了，想把分辨率调高一些。在“系统-&gt;首选项”里面看到了屏幕分辨率，打开一看，竟然有我显示器推荐使用的1440&#215;900，当即就选了。然后用Ctrl+Alt+Enter让VMware进入全屏模式，就像真的用Ubuntu一样！</p>
<p>因为这次打开Ubuntu的主要目的是学习LAMP，于是就装起了相关的东西。一开始的时候不知道新立得就有LAMP-Server，还傻傻的装了好多东西：</p>

<div class="wp_codebox"><table><tr id="p8737"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p87code37"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> apache2 mysql-server
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> php5-common php5-gd php5-mysql libapache2-mod-php5
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> phpmyadmin</pre></td></tr></table></div>

<p>其实并没有上面这条命令这么顺利的，我是绕了不少弯路。开始的时候apache2装上去然后装php5，然后我很快找到了位于/var/www/的网站目录。接着就在里面放上了一个“Hello World!”的php：</p>

<div class="wp_codebox"><table><tr id="p8738"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p87code38"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Hello World!&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>但是不能解析……结果后来知道，要重启一下apache2：</p>

<div class="wp_codebox"><table><tr id="p8739"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p87code39"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>apache2 restart</pre></td></tr></table></div>

<p>后来装完mysql后去下载了一个phpmyadmin解压到/var/www/目录里，结果不能访问，说是php没有加载mysql模块，我就囧了。后来把这个文件夹删了，然后用apt的phpmyadmin，在/etc/apache2/sites-available/文件夹里的default文件的虚拟服务器中添加了：</p>

<div class="wp_codebox"><table><tr id="p8740"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p87code40"><pre class="apache" style="font-family:monospace;">    <span style="color: #00007f;">Alias</span> /phpmyadmin/ <span style="color: #7f007f;">&quot;/usr/share/phpmyadmin/&quot;</span>
&nbsp;
        <span style="color: #00007f;">Options</span> <span style="color: #0000ff;">none</span>
        <span style="color: #00007f;">AllowOverride</span> Limit
        <span style="color: #00007f;">Order</span> <span style="color: #00007f;">Deny</span>,<span style="color: #00007f;">Allow</span>
        <span style="color: #00007f;">Deny</span> from <span style="color: #0000ff;">all</span>
        <span style="color: #00007f;">Allow</span> from <span style="color: #0000ff;">all</span></pre></td></tr></table></div>

<p>终于是可以用了。</p>
<p>刚刚升级了一下VMware到6.0，貌似宿主机和虚拟机可以一起上网了。另外终于是把VMware Tools给装上去了。也不知道是怎么装的，莫名其妙就装好了，所以就不写了。</p>
<p>我能这么还算顺利的做完这些事情，很大程度要感谢前辈们的指导。今天配置的过程中参考了许多来自不同地方的资料，其中帮助最广泛和最大的要数<a href="http://wiki.ubuntu.org.cn/index.php?title=Qref/Hardy&amp;variant=zh-cn" target="_blank">快速配置教程</a>了，其中的精细的指导实在是好，让我这样愚笨的人都在短时间内完成了一些东西。</p>
<p>最后赞叹一下这些伟大的自由软件的精妙和强大，实在是一个值得深究的东西啊！</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.upsuper.org/ubuntu-trip-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>下载PHP文件</title>
		<link>http://blog.upsuper.org/download-php-file/</link>
		<comments>http://blog.upsuper.org/download-php-file/#comments</comments>
		<pubDate>Wed, 30 Apr 2008 12:40:00 +0000</pubDate>
		<dc:creator>upsuper</dc:creator>
				<category><![CDATA[雕虫小技]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.upsuper.org/?p=33</guid>
		<description><![CDATA[今天把一个PHP文件放到下载目录去，但是会自动解析。于是就查了各种资料如何阻止Apache解析指定目录的PHP，但是查到的几种方法都不行，似乎是因为服务器的原因？httpd.conf的权限自然不是在我的。
我就换了一种想法，用URL Rewrite试试？把php文件改名后编写了一个.htaccess，把所有.php的文件rewrite到.php_file上去，终于成功实现了！

那个.htaccess代码：

1
2
3
RewriteEngine	on
RewriteBase	/
RewriteRule	^(.*)\.php$	$1\.php_file

另外，也把找到的其他方法给大家参考，都是通过编写.htaccess文件：
第一种是通过重定义php的MIMI-TYPE：

1
AddType text/html .php

第二种是通过关闭PHP引擎，这是PHP手册上所写的方法：

1
php_flag engine off

还有一种是直接禁止对一切PHP的访问：

1
2
3
4
&#60;Files  ~  &#34;.php&#34;&#62;
	Order allow, deny
	Deny from all
&#60;/Files&#62;

]]></description>
			<content:encoded><![CDATA[<p>今天把一个PHP文件放到下载目录去，但是会自动解析。于是就查了各种资料如何阻止Apache解析指定目录的PHP，但是查到的几种方法都不行，似乎是因为服务器的原因？httpd.conf的权限自然不是在我的。</p>
<p>我就换了一种想法，用URL Rewrite试试？把php文件改名后编写了一个.htaccess，把所有.php的文件rewrite到.php_file上去，终于成功实现了！<br />
<span id="more-33"></span><br />
那个.htaccess代码：</p>

<div class="wp_codebox"><table><tr id="p3345"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p33code45"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">RewriteEngine</span>	<span style="color: #0000ff;">on</span>
<span style="color: #00007f;">RewriteBase</span>	/
<span style="color: #00007f;">RewriteRule</span>	^(.*)\.php$	$<span style="color: #ff0000;">1</span>\.php_file</pre></td></tr></table></div>

<p>另外，也把找到的其他方法给大家参考，都是通过编写.htaccess文件：</p>
<p>第一种是通过重定义php的MIMI-TYPE：</p>

<div class="wp_codebox"><table><tr id="p3346"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p33code46"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">AddType</span> text/html .php</pre></td></tr></table></div>

<p>第二种是通过关闭PHP引擎，这是PHP手册上所写的方法：</p>

<div class="wp_codebox"><table><tr id="p3347"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p33code47"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">php_flag</span> engine <span style="color: #0000ff;">off</span></pre></td></tr></table></div>

<p>还有一种是直接禁止对一切PHP的访问：</p>

<div class="wp_codebox"><table><tr id="p3348"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p33code48"><pre class="apache" style="font-family:monospace;">&lt;<span style="color: #000000; font-weight:bold;">Files</span>  ~  <span style="color: #7f007f;">&quot;.php&quot;</span>&gt;
	<span style="color: #00007f;">Order</span> <span style="color: #00007f;">allow</span>, <span style="color: #00007f;">deny</span>
	<span style="color: #00007f;">Deny</span> from <span style="color: #0000ff;">all</span>
&lt;/<span style="color: #000000; font-weight:bold;">Files</span>&gt;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.upsuper.org/download-php-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
