`
xiaoshenge
  • 浏览: 167060 次
  • 性别: Icon_minigender_1
  • 来自: 十堰
社区版块
存档分类
最新评论

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

0
11
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics