2014-04-03 15:16:01
来 源
itjs.cn
Apache
本文介绍Apache服务器中配置python运行环境,希望对于初学Apache服务器相关的朋友有帮助,更多Apache安装、配置、报错处理等资源请本站内搜索。

这几天准备先了解下Python,先把环境配好再说

 

因为我一直接是用php做开发的,所以我用Apache+mod_python+mysql_python 

NameVirtualHost *:8080

<VirtualHost *:8080>

        ServerName www.investigation.com

        ServerAlias investigation

        DocumentRoot "D:/Project/sinotrac/investigation"

        <directory "D:/Project/sinotrac/investigation">

AllowOverride None

                Options Indexes FollowSymLinks

                Order allow,deny

                Allow from all

        </directory>

        <Location "/">

                SetHandler python-program

                PythonPath "['D:/Project/sinotrac'] + sys.path"

                PythonHandler django.core.handlers.modpython

                SetEnv DJANGO_SETTINGS_MODULE investigation.settings

                PythonOption django.root /investigation

                PythonDebug On

        </Location>

        Alias /site_media "D:/Project/sinotrac/investigation/media"

        Alias /media "C:/Python25/Lib/site-packages/django/contrib/admin/media"

        <Directory "C:/Python25/Lib/site-packages/django/contrib/admin/media/">

            Order deny,allow

            Allow from all

        </Directory>

        <Location "/media">

            SetHandler None

        </Location>

        <Location "/site_media">

            SetHandler None

        </Location>

        <Location "/admin_media">

            SetHandler None

        </Location>

#        <LocationMatch ".(jpg|gif|png|css|js)$">

#            SetHandler None

#        </LocationMatch>

</VirtualHost> 

嘿嘿。。我没有用django框架了,所以做了个简单配置

<VirtualHost 192.168.1.47>

    ServerName py.ww.com

    DocumentRoot F:Python

    <Directory "F:Python">

        #AddHandler mod_python .py

        SetHandler mod_python

        PythonHandler mod_python.publisher

        PythonDebug On

        Options FollowSymLinks

        AllowOverride FileInfo

    </Directory>

    <Files ~ ".(gif|html|jpg|png)$">

        SetHandler default-handler

    </Files>

</VirtualHost>

在根目录下新建index.py,内容如下:

#coding:gb2312

def index(req):

    req.write("This is the Index!")

    return

def hello(req):

    req.write("hello!!!")

    return

def get(req,name=""):

    if name:

       req.write("参数:"+name);

    else:

       req.write("no param.");

    return

 

声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。