Windows环境下使用Apache+mod_wsgi部署webpy

1、安装Python和Apache。

2、安装mod_wsgi后获得wsgi.so,并将wsgi.so放到Apache的modules文件夹下。

3、安装webpy。

4、打开httpd.conf(在Apache的conf文件夹下)

在文件的最后加上:

 

 LoadModule wsgi_module /modules/mod_wsgi.so

WSGIScriptAlias /webapp "D:/develop/webapp/index.py/"

 

Alias /webapp/static "D:/develop/webapp/static/"

AddType text/html .py

 

<Directory "D:/develop/webapp/">

    AllowOverride all

    Options Indexes FollowSymLinks  ExecCGI

    Order allow,deny

    SetHandler wsgi-script

    Allow from all

</Directory>

 

访问localhost/webapp,就可以访问D:/develop/webapp/index.py

index.py:

import web

        

urls = (

    '/(.*)', 'hello'

)

app = web.application(urls, globals())



class hello:        

    def GET(self, name):

        if not name: 

            name = 'World'

        return 'Hello, ' + name + '!'



if __name__ == "__main__":

    app.run()

 

若不可以访问可以尝试打开防火墙:

控制面板-》系统安全-》允许程序通过Windows防火墙-》允许运行另一程序

添加Apache的bin文件夹httpd.exe,并把后面的两个勾打上。


你可能感兴趣的:(windows)