mod_wsgi is a new Apache module which typically outperforms mod_python for hosting WSGI applications, and is very easy to set up.
At the end of your code.py, add:
app = web.application(urls, globals(), autoreload=False) application = app.wsgifunc()
mod_wsgi offers many possible ways to expose a WSGI application in Apache\'s URL hierarchy, but one simple way would be to add the following to your .htaccess:
<Files code.py> SetHandler wsgi-script Options ExecCGI FollowSymLinks </Files>
If you get an "ImportError: No module named web" in your apache error.log file, you could try setting the absolute path in code.py before importing web:
import sys, os abspath = os.path.dirname(__file__) sys.path.append(abspath) os.chdir(abspath)
Important: Donnot forget create the .htaccess file, otherwise an internal error will be caused when call a function in other custom modules. |