1,首先下载web.py: git clone git://github.com/webpy/webpy.git
2, 下载和安装mod_wsgi从它的网站:
. 它将安装一个'.so'的模块到您的apache 模块文件夹: /usr/lib64/httpd/modules/
3, 在httpd.conf中配置Apache 加载 mod_wsgi模块和您的项目:
LoadModule wsgi_module modules/mod_wsgi.so
WSGIScriptAlias /appname /var/www/webpy-app/code.py/
Alias /appname/static /var/www/webpy-app/static/
AddType text/html .py
<Directory /var/www/webpy-app/>
AllowOverride None
Options None
Order deny,allow
Allow from all
</Directory>
演示文件 'code.py':
import web
urls = ( '/.*', 'hello', )
class hello:
def GET(self):
return "Hello, world."
application = web.application(urls, globals()).wsgifunc()
4,如果您需要在mod_wsgi中使用sessions,您可以改变您的代码如下:
app = web.application(urls, globals())
curdir = os.path.dirname(__file__)
session = web.session.Session(app, web.session.DiskStore(curdir + '/' + 'sessions'),)
application = app.wsgifunc()