Progetto

Generale

Profilo

TracMultipleProjects » Cronologia » Versione 2

Anonimo, 07-11-2005 15:00

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