标签:
首先安装好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
下载安装web.py模块:
easy_install -U web.py
或者手动下载安装:
1.下载地址: http://webpy.org
2.解压到任意目录,进入目录python setup.py install,安装完毕后打开idle编辑器测试是否安装成功:
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,查看是否能正常显示
开始设置
比如我以后想把试用web.py的程序都放在d:\develop\webapp目录下,并且访问连接为:127.0.0.1/webapp
配置如下:
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, 配置完毕。
windows下apache+wsgi+web.py环境搭建
标签:
原文地址:http://www.cnblogs.com/jsben/p/4643698.html