Edgewall Software

Version 3 (modified by Jonas Borgström, 20 years ago) ( diff )

Configure apache for multiple projects

By following these instruction you will get an Apache server that automatically handles multiple projects for you.

Start out by creating an projects directory in your documentroot (/var/www in this example). Projects will be accessed by http://hostname/projects/projectname. Copy (or symlink) trac.cgi to this directory together with a file named index.html. This will be showed when users try to access non-existing 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. Edit you apache config and add this:

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

<Directory "/var/www/projects">
	AllowOverride None
	Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
	AddHandler cgi-script .cgi
	Order allow,deny
	Allow from all
</Directory>

<Location "/projects/[[:alnum:]]+/login">
	AuthType Basic
	AuthName "trac"
	AuthUserFile /path/to/trac.htpasswd
	Require valid-user
</location>

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 to much work, replace it with a php script that does it for you.


See also: TracGuide, TracInstall

Note: See TracWiki for help on using the wiki.