Edgewall Software

Version 3 (modified by daniel, 19 years ago) ( diff )

Edited and added text about multiple projects

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 two obvious workarounds to make things work:

  1. Recompile suexec to let it pass the TRAC_ENV variable; which requires root permissions and is not really advisable anyway.
  2. 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.

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

Note: See TracWiki for help on using the wiki.