This document is intended to convey a best-practice method of deploying TurboGears using mod_python. It assumes that you have mod_python installed and enabled in your Apache web server.
For this example, our project name will be "ProjectName".
Install Jamie Turner's mpcp script:
sudo easy_install -Z mpcp
For compatibility with mod_python, you must remove or replace the hyphen in your ProjectName-start.py file. In this example we'll replace the hyphen with an underscore:
mv ProjectName-start.py ProjectName_start.py
Create an .htaccess file in your project directory with the following:
SetHandler mod_python PythonHandler mpcp PythonDebug On PythonOption cherrysetup ProjectName_start.py::mp_setup
Now make these changes in your ProjectName_start.py:
1) Have it start the CP server only when called directly:
2) Create a no-op mp_setup() method:
Restart your Apache server and you should be up and running with TurboGears on mod_python.
A little more work is required to get this running on a Linux machine. We need to correctly map file paths by modifying our start script: