首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > perl python >

win7上搭建python环境

2012-10-28 
win7下搭建python环境记得以前在ubuntu下搭建python开发环境也就几条命令,谁知道换成ubuntu11.04系统没那

win7下搭建python环境

记得以前在ubuntu下搭建python开发环境也就几条命令,谁知道换成ubuntu11.04系统没那么好用折腾半天都没搞好,只好在win7下搭建。发现有点麻烦就记录一下。

所需软件:apahce2.2,python5.1(被xx) mod_python(http://archive.apache.org/dist/httpd/modpython/)

先安装好apahce2.2,python5.1,在安装mod_python(需要选择apache的安装路径)。

配置:

LoadModule python_module modules/mod_python.so 添加到apche配置文件

配置虚拟主机:

<VirtualHost 127.0.0.1>
??? DocumentRoot D:/code/python
?? ??? ServerName mypy.com
??? <Directory D:/code/python>
??????? ??? AddHandler mod_python .py
??????? ??? PythonHandler index
??????? ??? PythonDebug On
??? ??? Options Includes FollowSymLinks
???????? ??? AllowOverride None
??? ??? Order deny,allow
??? ??? ??? allow from all
??? ??? </Directory>
</VirtualHost>

写一个文件来测试一下。在 D:/code/python下新建文件index.py,内容如下:

from mod_python import apache

def handler(req):
? ? req.write("Hello World!")
? ? return apache.OK

注意:这里的index.py与PythonHandler index有关,具体原因有待研究。

mod_python文档:http://man.chinaunix.net/develop/python/mod_python/mod_python.html#head-f43fb742b32fd6930e7c30926f22c88fcfe019e5

热点排行