= Configure Apache for multiple projects = By following these instructions, you will set up Apache to automatically serve multiple Trac projects for you. Start out by creating a project directory in your documentroot (/var/www in this example). Projects will be accessed as http://hostname/projects/projectname. Copy (or symlink) trac.cgi to this directory together with a file named index.html. This will be shown when users try to access nonexistent projects. Then create your trac projects with trac-admin. It's important that they are all placed in the same directory. In this example we'll use /var/lib/trac. Add to your Apache configuration: {{{ RewriteEngine on RewriteRule ^/projects/+$ /projects/index.html [L] RewriteCond /var/lib/trac/$1 -d RewriteRule ^/projects/([[:alnum:]]+)(/?.*) /projects/trac.cgi$2 [S=1,E=TRAC_ENV:/var/lib/trac/$1] RewriteRule ^/projects/(.*) /projects/index.html AllowOverride None Options ExecCGI -MultiViews +SymLinksIfOwnerMatch AddHandler cgi-script .cgi Order allow,deny Allow from all AuthType Basic AuthName "trac" AuthUserFile /path/to/trac.htpasswd Require valid-user }}} Or for windows systems: {{{ RewriteEngine on RewriteRule ^/projects/+$ /projects/index.html [L] #RewriteCond /var/lib/trac/$1 -d RewriteCond d:/svn/$1.db -d RewriteRule ^/projects/([[:alnum:]]+)(/?.*) /projects/trac.cgi$2 [S=1,E=TRAC_ENV:d:/svn/$1.db] RewriteRule ^/projects/(.*) /projects/index.html AllowOverride None Options ExecCGI -MultiViews +SymLinksIfOwnerMatch AddHandler cgi-script .cgi Order allow,deny Allow from all AuthType Basic AuthName "trac" AuthUserFile D:/svn/.htaccess Require valid-user }}} Make sure you have the rewrite module loaded or compiled in Apache. {{{LoadModule rewrite_module modules/mod_rewrite.so}}} Now, when you add another project, you don't need to edit any apache config. The only file you may want to edit is index.html to make it list the new project. If you think this is too much work, replace it with a python cgi script that does it for you. [wiki:TracStandalone tracd] and ModPython can also serve multiple projects. ---- If you have a normal account on a Unix server and you can have your own cgi-scripts launched by suExec, then you can setup trac to serve multiple projects. The main problem is that suExec cleans up your environment and "!SetEnv TRAN_ENV ..." have no effect. I use the following setup. I install Clearsilver: {{{ ./configure --prefix=$HOME/sw make make install cp python/neo_cgi.so ~/sw/lib/python2.3/site-packages/ }}} I install trac: {{{ ./setup.py install --prefix=$HOME/sw cp ~/sw/share/trac/cgi-bin/trac.cgi ~/public_html }}} I create ~/public_html/.htaccess (change "marcenuc" with your username): {{{ Options +ExecCGI DirectoryIndex index.cs index.html Action cs-handler /~marcenuc/static.cgi AddHandler cs-handler .cs AddType text/html .cs RewriteEngine On RewriteBase /~marcenuc RewriteRule ^prj/?$ projects [R,L] RewriteCond /home/marcenuc/.trac/prj/$1 -d RewriteRule ^prj/([[:alnum:]]+)(/?.*) trac-wrapper.cgi/$1$2 [S=1] RewriteRule ^prj/(.*) projects [R,L] }}} I create ~/public_html/trac-wrapper.cgi (change "marcenuc" with your username) and make it executable: {{{ #!/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 }}} Create your projects repository and trac-environment: {{{ mkdir -p ~/.trac/{prj,svn} svnadmin create ~/.trac/svn/myfirstproject trac-admin ~/.trac/svn/myfirstproject initenv }}} Open http://severname/~username/prj/myfirstproject ---- See also: TracGuide, TracInstall