Changes between Version 53 and Version 54 of TracMultipleProjects
- Timestamp:
- Jun 17, 2005, 1:32:20 PM (19 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TracMultipleProjects
v53 v54 1 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. There are two different ways of setting this up: with and without global authentication. 4 5 == URL Rewriting == 6 7 8 Both ways use Apache's URL rewriting module : {{{mod_rewrite}}}. You have to make sure you have it loaded or compiled in Apache. 2 By following these instructions, you will set up Apache to automatically serve multiple Trac projects for you. There are two different ways of setting this up: with and without global authentication. And with Apache 2 there are even two ways to do both. 3 4 == Easiest method for hosting multiple projects in one domain with Apache 2 == 5 The first way to support multiple projects is to add the following to the Apache 2 config file, per project (myproj in this case): 6 7 {{{ 8 ScriptAlias /myproj /path/to/trac.cgi 9 10 <Location "/myproj"> 11 SetEnv TRAC_ENV "/var/trac/myproj" 12 </Location> 13 14 <Location "/myproj/login"> 15 AuthType basic 16 AuthName "myproj - trac" 17 AuthUserFile "/var/svn/svn-auth-file" 18 Require valid-user 19 </Location> 20 }}} 21 22 This is in addition to the global line: 23 24 {{{ 25 Alias /trac "/usr/share/trac/htdocs" 26 }}} 27 28 If you want different users per project, just edit the !AuthUserFile line for each one. 29 30 == Harder method: URL Rewriting == 31 In this case both ways use Apache's URL rewriting module : {{{mod_rewrite}}}. You have to make sure you have it loaded or compiled in Apache. 9 32 10 33 === Apache 1.x === 11 12 34 In 1.x versions of the Apache web server, you must uncomment the following line in the main Apache configuration file, generally found at {{{/etc/apache/apache.conf}}} or {{{/etc/httpd/httpd.conf}}} : 13 35 … … 17 39 18 40 === Apache 2.x === 19 20 41 Newer versions of Apache (> 2.x) uses a cleaner configuration system. In the directory {{{/etc/apache2/mods-available/}}} are all modules loading and configuration snippets available. In {{{/etc/apache2/mods-enabled/}}} are all enabled modules. You just need to check that a symlink to the rewrite module loading file is present. If not, create it : 21 42 … … 31 52 }}} 32 53 33 == Global == 34 54 == Global authentication == 35 55 This is the simplest case. With this procedure, you will be able to serve multiple Trac projects, using the same user accounts for every projects (permissions are still per project, but authentication is not). This is the original procedure provided by the Trac team. 36 56 … … 79 99 '''Suggestion:''' In the second ''RewriteRule'' directive and in the ''LocationMatch'' directive, change {{{[[:alnum:]]}}} to {{{[^/]}}} because while {{{[[:alnum:]]}}} only matches an alpha-numeric character, {{{[^/]}}} matches any character that is not a slash. This change allows for, among other things, hyphens in project/directory names. Another possibility is to replace {{{[[:alnum:]]}}} with {{{[[:alnum:]\-]}}}, which matches only an alphanumeric character or a hyphen (the backslash "escapes" the hyphen, which would otherwise have special meaning). The [http://httpd.apache.org/docs-2.0/mod/mod_rewrite.html Apache 2.0 mod_rewrite documentation] suggests referencing the Perl regular expression manual page (run {{{perldoc perlre}}} on a system where Perl is installed) for details on regular expressions. Note that it may be preferable to use a pattern that matches only characters suitable for directory names (and, thus, project names) that are valid for your particular installation. 80 100 81 == Per-project == 82 101 == Per-project authentication == 83 102 As you problably noticed, the global procedure described above uses the same {{{AuthUserFile}}}, so every user you create in this file can log in every Trac project you host. Of course, in a non-configured Trac env, this user will be considered as ''anonymous'', but you might not want this too. Using a per-project authentification also allows you to use a different authentification greater for each project. 84 103 … … 86 105 87 106 === Preparation === 88 89 107 As for the first procedure, you'll need a {{{projects}}} directory into your !DocumentRoot. Copy or symlink {{{trac.cgi}}} to this project : 90 108 … … 97 115 98 116 === Apache configuration === 99 100 117 The begining is exactly the same than for the global authentification installation : 101 118 … … 155 172 156 173 === Auth files and project listing === 157 158 174 In order to complete this setup, you will need two authentification files : 159 175 … … 211 227 Here you are ! Don't forget to ''chown'' these files to {{{www-data}}}, and it should work ! 212 228 213 === Alternative method for hosting multiple projects in one domain ===214 215 Another way to support multiple projects is to add the following to the Apache 2 config file, per project (myproj in this case):216 217 {{{218 ScriptAlias /myproj /219 220 <Location "/myproj">221 SetEnv TRAC_ENV "/var/trac/myproj"222 </Location>223 224 <Location "/myproj/login">225 AuthType basic226 AuthName "trac"227 AuthUserFile "/var/svn/svn-auth-file"228 Require valid-user229 </Location>230 }}}231 232 This is in addition to the global line:233 234 {{{235 Alias /trac "/usr/share/trac/htdocs"236 }}}237 238 If you want different users per project, just edit the !AuthUserFile line for each one.239 240 229 ------- 241 230 See also: TracGuide, TracInstall, TracMultipleProjectsWindows