| 1 | = Configure Apache for multiple projects = |
| 2 | |
| 3 | By following these instructions, you will set up Apache to automatically serve multiple Trac projects for you. |
| 4 | |
| 5 | 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. |
| 6 | |
| 7 | 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: |
| 8 | |
| 9 | {{{ |
| 10 | RewriteEngine on |
| 11 | RewriteRule ^/projects/+$ /projects/index.html [L] |
| 12 | RewriteCond /var/lib/trac/$1 -d |
| 13 | RewriteRule ^/projects/([[:alnum:]]+)(/?.*) /projects/trac.cgi$2 [S=1,E=TRAC_ENV:/var/lib/trac/$1] |
| 14 | RewriteRule ^/projects/(.*) /projects/index.html |
| 15 | |
| 16 | <Directory "/var/www/projects"> |
| 17 | AllowOverride None |
| 18 | Options ExecCGI -MultiViews +SymLinksIfOwnerMatch |
| 19 | AddHandler cgi-script .cgi |
| 20 | Order allow,deny |
| 21 | Allow from all |
| 22 | </Directory> |
| 23 | |
| 24 | <LocationMatch "/projects/[[:alnum:]]+/login"> |
| 25 | AuthType Basic |
| 26 | AuthName "trac" |
| 27 | AuthUserFile /path/to/trac.htpasswd |
| 28 | Require valid-user |
| 29 | </LocationMatch> |
| 30 | }}} |
| 31 | |
| 32 | Make sure you have the rewrite module loaded or compiled in Apache. |
| 33 | |
| 34 | {{{LoadModule rewrite_module modules/mod_rewrite.so}}} |
| 35 | |
| 36 | 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. |
| 37 | |
| 38 | [wiki:TracStandalone tracd] and TracModPython can also serve multiple projects. |
| 39 | |
| 40 | |
| 41 | ---- |
| 42 | See also: TracGuide, TracInstall |