| 98 | |
| 99 | === Alternative frontend: mod_python === |
| 100 | |
| 101 | Virtualenv can also be used with Apache and mod_python, but as mod_python will be a system install it will not be aware of the virutalenv without some configuration. For development this is useful as one Apache can serve various development versions in a more permanent way. This method will use the system Python, but will add the libraries from the virtualenv. |
| 102 | |
| 103 | '''Step 1:''' Make a new frontend script that for instance can be stored in the virtualenv 'bin' directory. |
| 104 | |
| 105 | {{{ |
| 106 | #!python |
| 107 | #myvirtualtrac.py |
| 108 | |
| 109 | import os |
| 110 | import site |
| 111 | site.addsitedir('/path/to/my/virtualenv/lib/python2.4/site-packages') |
| 112 | |
| 113 | from trac.web.modpython_frontend import handler |
| 114 | }}} |
| 115 | |
| 116 | '''Step 2:''' Update Apache config to use this script - add or update options according to the default mod_python setup like for instance found in TracModPython. |
| 117 | |
| 118 | {{{ |
| 119 | # Extend the path so Apache will find your script on path |
| 120 | PythonPath "['/path/to/my/virtualenv/bin'] + sys.path" |
| 121 | |
| 122 | # Make mod_python use new frontend instead of trac.web.modpython_frontend |
| 123 | PythonHandler myvirtualtrac |
| 124 | }}} |