Version 4 (modified by 19 years ago) ( diff ) | ,
---|
Trac and Apache suEXEC
Trac in CGI-mode doesn't play very well with Apache suEXEC.
Setting the TRAC_ENV environment variable as described in TracInstall will not work when using suEXEC feature because the environment variables are filtered and only a limited subset reaches the CGI program.
There are obvious workarounds to make things work:
- Recompile suexec to let it pass the TRAC_ENV variable; which requires root permissions and is not really advisable anyway.
- Change our trac.cgi script to set the TRAC_ENV variable by itself, to do this we edit trac.cgi file and add
import os;os.environ['TRAC_ENV'] = '/path/to/projectenv'
at the very beginning of the script. - Make a wrapper script
#!/bin/bash export TRAC_ENV='/path/to/projectenv' exec /path/to/trac/trac.cgi
Note: This is a kludge, but works.
Multiple Projects under suEXEC
When hosting multiple projects under suEXEC, you can either copy the CGI script and change the TRAC_ENV setting for each script, or make a wrapper script around it.
Here's a contributed script to work around the stripping of environment variables done by suEXEC.
#!/bin/bash user="marcenuc" prj="${PATH_INFO#/}" prj="${prj%%/*}" export TRAC_ENV="/home/${user}/.trac/prj/${prj}" export SCRIPT_NAME="/~${user}/prj/${prj}" export PATH_INFO="${PATH_INFO#/${prj}}" export PYTHONPATH="/home/${user}/sw/lib/python2.3/site-packages" exec ./trac.cgi
See also: TracInstall, TracMultipleProjects