Steps:
-
Download and install mod_wsgi from its website: http://code.google.com/p/modwsgi/. It will install a ".so" module in Apache module directory. e.g.
/usr/lib64/httpd/modules/
-
Configure Apache to load mod_wsgi module and your project in httpd.conf:
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/> Order deny,allow Allow from all </Directory>
-
Sample file "code.py":
import web
urls = ( "/.*", "hello", )
class hello: def GET(self): return "Hello, world."
application = web.application(urls, globals()).wsgifunc()
-
Point your browser to "http://your_server_name/appname" to verify whether it works for you.
Note: mod_wsgi + sessions
If you use sessions with mod_wsgi, you should change you code like below:
app = web.application(urls, globals())
curdir = os.path.dirname(__file__) session = web.session.Session(app, web.session.DiskStore(curdir + "/" + "sessions"),)
application = app.wsgifunc()
|