The following steps passed the test in Apache-2.2.3 (RedHatEnterpriseLinux5.2, x86_64), mod_wsgi-2.0. Note: You can replace the appname with your own project name. You can use your own file name to replace
The following steps are performed in Apache-2.2.3 (REdHat Enterprise Linux 5.2, x86_64), tested in mod_wsgi-2.0. I have passed the test in Windows2003 + Apache-2.2.15 + mod_wsgi-3.0)
Note:
- You can replace 'appname' with your own project name '.
- You can replace 'Code. py' with your own file name '.
- /Var/www/webpy-app is the directory path of the folder containing your code. py.
- /Var/www/webpy-app/code. py is the complete path of your python file.
Steps:
- Download and install mod_wsgi from its website:
Http://code.google.com/p/modwsgi/. It will install a '. so' module to your apache module folder, for example:
/usr/lib64/httpd/modules/
-
In httpd. conf, configure Apache to load the mod_wsgi module and your project:
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
Order deny,allow Allow from all
-
Demo file 'Code. py ':
import web urls = ( '/.*', 'hello', ) class hello: def GET(self): return "Hello, world." application = web.application(urls, globals()).wsgifunc()
-
Enter 'HTTP: // your_server_name/appname' in the address bar of your browser to verify whether it is available.
Note: mod_wsgi + sessions
If you need to use sessions in mod_wsgi, you can change your Code as follows:
app = web.application(urls, globals())curdir = os.path.dirname(__file__)session = web.session.Session(app, web.session.DiskStore(curdir + '/' + 'sessions'),)application = app.wsgifunc()
Mod_wsgi performance:
For more information about mod_wsgi performance, see the mod_wsgi wiki: http://code.google.com/p/modwsgi/wiki/PerfoRmAnceEstimates