<?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://mmlst.com/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://mmlst.com</link>
	<description>分享知识</description>
	<lastBuildDate>Fri, 07 Aug 2009 01:14:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Linux下配置Apache服务器运行Python script</title>
		<link>http://mmlst.com/2009/05/23/linux%e4%b8%8b%e9%85%8d%e7%bd%aeapache%e6%9c%8d%e5%8a%a1%e5%99%a8%e8%bf%90%e8%a1%8cpython-script/</link>
		<comments>http://mmlst.com/2009/05/23/linux%e4%b8%8b%e9%85%8d%e7%bd%aeapache%e6%9c%8d%e5%8a%a1%e5%99%a8%e8%bf%90%e8%a1%8cpython-script/#comments</comments>
		<pubDate>Sat, 23 May 2009 11:40:05 +0000</pubDate>
		<dc:creator>mmlst</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[ExecCGI]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://mmlst.com/?p=174</guid>
		<description><![CDATA[这里不讲Apache和Python的安装。安装方式可以直接是apt-get install或者用新立得，或者去他们网站下载最新的自己进行编译安装。
安装好后，打开/etc/apache2/下的httpd.conf文件，输入“AddHandler cgi-script .cgi .py”。
跟在Windwos下配置一样，ExecCGI也是需要加入，否则一样会碰到Forbidden问题。解决办法是：
找到/etc/apache2/sites-available目录，或自己定义的目录，然后修改里面的default文件，找到
&#60;Directory /var/www/&#62;
Options FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
&#60;/Directory&#62;
在Options FollowSymLinks MultiViews后面加上ExecCGI (或&#8221;+ExecCGI&#8221;都可)。
]]></description>
		<wfw:commentRss>http://mmlst.com/2009/05/23/linux%e4%b8%8b%e9%85%8d%e7%bd%aeapache%e6%9c%8d%e5%8a%a1%e5%99%a8%e8%bf%90%e8%a1%8cpython-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows下配置Apache以便在浏览器中运行Python script的CGI模式</title>
		<link>http://mmlst.com/2009/05/23/windows%e4%b8%8b%e9%85%8d%e7%bd%aeapache%e4%bb%a5%e4%be%bf%e5%9c%a8%e6%b5%8f%e8%a7%88%e5%99%a8%e4%b8%ad%e8%bf%90%e8%a1%8cpython-script%e7%9a%84cgi%e6%a8%a1%e5%bc%8f/</link>
		<comments>http://mmlst.com/2009/05/23/windows%e4%b8%8b%e9%85%8d%e7%bd%aeapache%e4%bb%a5%e4%be%bf%e5%9c%a8%e6%b5%8f%e8%a7%88%e5%99%a8%e4%b8%ad%e8%bf%90%e8%a1%8cpython-script%e7%9a%84cgi%e6%a8%a1%e5%bc%8f/#comments</comments>
		<pubDate>Sat, 23 May 2009 05:57:05 +0000</pubDate>
		<dc:creator>mmlst</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[CGI]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://mmlst.com/?p=153</guid>
		<description><![CDATA[在前面的我的一篇文章中 “Windows XP下的Python 首次安装配置和使用”谈到当想在Apache服务器下运行Python script的时候，发现Apache的mod_python版本还不支持Python 2.6更别说3.0.1了，只有2.5之下的，折腾着卸载和安装，最后还没搞定，就先搁一边了。
现在因为已经安装了2.6的Python，以及支持2.6的Eric4，就不想再重新安装2.5来继续配置Apache下mod_python了。
后来发现了一篇文章Running Python as CGI in Apache in Windows，讲述以CGI模式代替mod_python来运行python script。还有这篇Python for Windows。
做法是：

打开httpd.conf，找到&#8221;#ScriptInterpreterSource Registry&#8220;，移除前面的注释# （如果找不到这行，就自己添加进去）
找到“Options Indexes FollowSymLinks”这句，在后面加上&#8221;ExecCGI&#8220;。(那个&#8221;Indexes&#8220;最好也能去掉，因为如果不去掉的话，目录下面没有index.html这种文件，就会显示出目录列表下的所有文件，所以有安全漏洞问题。如果去掉Indexes，而且没有index.html文件的话，就会显示一个Forbidden页面)
找到&#8221;AddHandler cgi-script .cgi&#8220;，在后面加上 .py。如果没有这句，可以自己添加 “AddHandler cgi-script .py”
重新启动Apache即可 （有的时候restart会导致Apache死掉，所以碰到这种情况的人可以stop先再start）

然后创建一个test.py script，
print "Content-type: text/html"
print ""
print "&#60;html&#62;&#60;head&#62;&#60;/head&#62;&#60;body&#62;"
print "Hello World"
print "&#60;/body&#62;&#60;/html&#62;"
注意第二句print &#8220;&#8221;不能少，如果没有这句，会引起一个 “500 Internal Server Error” 错误。
在浏览器中运行http://localhost/test.py，Hello World两个字被输出后表明运行正常。
另外，有些错误提示如下：

没有添加ScriptInterpreterSource Registry，会出现500 Internal Server Error错误。
没有添加ExecCGI，会出现403 Forbidden You don&#8217;t have permission to access /test.py on [...]]]></description>
		<wfw:commentRss>http://mmlst.com/2009/05/23/windows%e4%b8%8b%e9%85%8d%e7%bd%aeapache%e4%bb%a5%e4%be%bf%e5%9c%a8%e6%b5%8f%e8%a7%88%e5%99%a8%e4%b8%ad%e8%bf%90%e8%a1%8cpython-script%e7%9a%84cgi%e6%a8%a1%e5%bc%8f/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows XP下的Python 首次安装配置和使用</title>
		<link>http://mmlst.com/2009/05/23/windows-xp%e4%b8%8b%e7%9a%84python-%e9%a6%96%e6%ac%a1%e5%ae%89%e8%a3%85%e9%85%8d%e7%bd%ae%e5%92%8c%e4%bd%bf%e7%94%a8/</link>
		<comments>http://mmlst.com/2009/05/23/windows-xp%e4%b8%8b%e7%9a%84python-%e9%a6%96%e6%ac%a1%e5%ae%89%e8%a3%85%e9%85%8d%e7%bd%ae%e5%92%8c%e4%bd%bf%e7%94%a8/#comments</comments>
		<pubDate>Sat, 23 May 2009 00:45:53 +0000</pubDate>
		<dc:creator>mmlst</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[PythonWin]]></category>

		<guid isPermaLink="false">http://mmlst.com/?p=143</guid>
		<description><![CDATA[Windows下的Python安装还是比较方便的，下载一个.exe文件，然后很快就可以安装好。
如果使用自身带的IDLE编辑器，直接就可以使用了。但它的方便对我来说仅限于此。(只是对我来说的)
看了好几个文章介绍不同的Python编辑器或IDE，一开始选择的是PythonWin(选择这个主要是因为当初在学校的时候老师教了点Python，用的就是这个，可惜当初没去学Python，一心钻研在PHP和其它东东上)
PythonWin的选择还要跟你安装的Python版本一样才可以，否则安装不了。（麻烦的开始，呵呵）
因为一开始我装的Python是最新的3.0.1，PythonWin没有这个版本的，有2.6和2.5的。。
只好卸载了Python3.0.1，然后重新下载2.6版，安装。再下载PythonWin2.6版的，安装。
不过PythonWin安装也是很简单，直接一路next就可以了。
安装好后，打开PythonWin，在提示符&#62;&#62;&#62;后面输入print &#8220;Hello World&#8221;，然后回车，不出错误的话，下面就会显示出来Hello World。
或者新建一个script，选择File &#8211; New &#8211; Python Script，在script里输入 print &#8220;Hello World&#8221;，保存一下先，然后按F5运行，在刚开始的&#62;&#62;&#62;提示符窗口中就会出现Hello World。(如果没有先保存，运行的时候会提示错误)
好，一个简单的Python环境就设好了，可以创建.py脚本了。
如果想在浏览器中运行.py脚本，需要配置一下Apache服务器来支持Python，需要mod_python插件。
当去Apache网站准备下载一个的时候，发现竟然没有支持2.6版本的。。。我晕。。只有2.5的，还是两年前做的。。
这个项目已经停止更新两年了么。。
没办法，重新卸载2.6的Python和PythonWin，然后再去下载2.5的，和mod_python，再重新进行安装。
不过在浏览器中打开.py的脚本的时候无法正常解析。
这个时候又卸载又安装的搞的头大，就没心情继续下去，准备暂时把这个缓一下，先把Python的教程读完再说。
]]></description>
		<wfw:commentRss>http://mmlst.com/2009/05/23/windows-xp%e4%b8%8b%e7%9a%84python-%e9%a6%96%e6%ac%a1%e5%ae%89%e8%a3%85%e9%85%8d%e7%bd%ae%e5%92%8c%e4%bd%bf%e7%94%a8/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
<html>
<head>
<title></title>
<meta name="verify-v1" content="g9TyLKV+Qw/waEbbIIFWqxWkvuCs7piVz1GOM0RuSuM=" />
</head>
<body>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-5977749-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>
</body>
</html>