首先安裝好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.sohtml
下載安裝web.py模塊:python
easy_install -U web.pyweb
下載安裝web.py模塊:apache
easy_install -U web.py瀏覽器
或者手動下載安裝:app
1.下載地址: http://webpy.org
2.解壓到任意目錄,進入目錄python setup.py install,安裝完畢後打開idle編輯器測試是否安裝成功:python2.7
1 >>> import web 2 >>> urls= ('/','index') 3 >>> app = web.application(urls,globals()) 4 >>> class index: 5 def GET(self): 6 return 'hello world!' 7 8 >>> app.run()
在瀏覽器中瀏覽127.0.0.1:8080,查看是否能正常顯示webapp
開始設置編輯器
好比我之後想把試用web.py的程序都放在d:\develop\webapp目錄下,而且訪問鏈接爲:127.0.0.1/webapp
配置以下:ide
1 LoadModule wsgi_module modules/mod_wsgi.so 2 3 WSGIScriptAlias /webapp "D:/develop/webapp/index.py/" 4 5 Alias /webapp/static "D:/develop/webapp/static/" 6 AddType text/html .py 7 8 <Directory "D:/develop/webapp/"> 9 AllowOverride all 10 Options Indexes FollowSymLinks ExecCGI 11 Order allow,deny 12 SetHandler wsgi-script 13 Allow from all 14 </Directory>
重啓apache。
測試是否成功:
編輯:d:/develop/webapp/index.py文件:
1 import web 2 urls = ('/','index') 3 4 class index: 5 def GET(self): 6 return "hello world!" 7 8 app = web.application(urls, globals(), autoreload=False) 9 application = app.wsgifunc()
訪問http://localhost/webapp, 配置完畢。