首先安装好wsgi模块并启用:
1.下载地址:我本机是python2.7 http://code.google.com/p/modwsgi/downloads/detail?name=mod_wsgi-win32-ap22py27-3.3.so
2.把mod_wsgi-win32-ap22py27-3.3.so放到apache安装目录下的modules目录下
3.打开 http.conf
添加:LoadModule wsgi_module modules/mod_wsgi-win32-ap22py27-3.3.so
下载安装web.py模块:
easy_install -U web.py
或者手动下载安装:
1.下载地址: http://webpy.org
2.解压到任意目录,进入目录python setup.py install,安装完毕后打开idle编辑器测试是否安装成功:
>>> import web >>> urls= ('/','index') >>> app = web.application(urls,globals()) >>> class index: def GET(self): return 'hello world!' >>> app.run()
在浏览器中浏览127.0.0.1:8080,查看是否能正常显示
开始设置
比如我以后想把试用web.py的程序都放在C:\develop\webapp目录下,并且访问连接为:127.0.0.1/webapp
配置如下:
LoadModule wsgi_module modules/mod_wsgi.so WSGIScriptAlias /webapp "C:/develop/webapp/index.py/" Alias /webapp/static "C:/develop/webapp/static/" AddType text/html .py AllowOverride all Options Indexes FollowSymLinks ExecCGI Order allow,deny SetHandler wsgi-script Allow from all
重启apache。
测试是否成功:
编辑:C:/develop/webapp/index.py文件:
import web urls = ('/','index') class index: def GET(self): return "hello world!" app = web.application(urls, globals(), autoreload=False) application = app.wsgifunc()
访问http://localhost/webapp, 配置完毕。
good job