文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Python Apache 安装配置

Python Apache 安装配置

时间:2010-03-12  来源:kkboy_dyc

版本 apache2.2 python 2.5.1 mod_python 3.3.1(下载地址 http://www.modpython.org)

下载mod_python安装文件,安装后配置apache中 http.conf文件

(我的py文件存放目录是c:/pysys)

加载如下内容:

Alias /py c:/pysys/

<Directory "c:/pysys">
Allow from all
AddHandler mod_python .prog
SetHandler mod_python
PythonHandler test
PythonDebug On
<FilesMatch "\.(py|pyc)">
Order allow,deny
Deny from all
</FilesMatch>
</Directory>

建立一个测试文件:


# mod_python test example - test.py
from mod_python import apache
from sys import version

def writeinfo(req,name,value):
    req.write("<DT>%s</DT><DD>%s</DD>\n" % (name,value))

def handler(req):
    req.content_type = "text/html"
    if req.header_only:
        return apache.OK

    req.write("""<HTML><HEAD><TITLE>mod_python is work</TITLE>
    </HEAD>
    <BODY>
    <H1>mod_python is working</H1>
    You have successfully configutred mod_python on your Apache system.
    Here is some information about the environment and this request:
    <P>
    <DL>
    """)

    writeinfo(req,"Client IP",req.get_remote_host(apache.REMOTE_NOLOOKUP))
    writeinfo(req,"URI",req.uri)
    writeinfo(req,"Filename",req.filename)
    writeinfo(req,"Canonical filename",req.canonical_filename)
    writeinfo(req,"Path_info",req.path_info)
    writeinfo(req,"Python version",version)

    req.write("</DL></BODY></HTML>\n")

    return apache.OK


输入 http://locahost/py
相关阅读 更多 +
排行榜 更多 +
找茬脑洞的世界安卓版

找茬脑洞的世界安卓版

休闲益智 下载
滑板英雄跑酷2手游

滑板英雄跑酷2手游

休闲益智 下载
披萨对对看下载

披萨对对看下载

休闲益智 下载