Edgewall Software

Changes between Version 53 and Version 54 of TracMultipleProjects


Ignore:
Timestamp:
Jun 17, 2005, 1:32:20 PM (19 years ago)
Author:
mechanix
Comment:

correct easy Apache 2 method and move to top

Legend:

Unmodified
Added
Removed
Modified
  • TracMultipleProjects

    v53 v54  
    11= 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.
     2By 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 ==
     5The 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{{{
     8ScriptAlias /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
     22This is in addition to the global line:
     23
     24{{{
     25Alias /trac "/usr/share/trac/htdocs"
     26}}}
     27
     28If you want different users per project, just edit the !AuthUserFile line for each one.
     29
     30== Harder method: URL Rewriting ==
     31In 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.
    932
    1033=== Apache 1.x ===
    11 
    1234In 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}}} :
    1335
     
    1739
    1840=== Apache 2.x ===
    19 
    2041Newer 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 :
    2142
     
    3152}}}
    3253
    33 == Global ==
    34 
     54== Global authentication ==
    3555This 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.
    3656
     
    7999'''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.
    80100
    81 == Per-project ==
    82 
     101== Per-project authentication ==
    83102As 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.
    84103
     
    86105
    87106=== Preparation ===
    88 
    89107As for the first procedure, you'll need a {{{projects}}} directory into your !DocumentRoot. Copy or symlink {{{trac.cgi}}} to this project :
    90108
     
    97115
    98116=== Apache configuration ===
    99 
    100117The begining is exactly the same than for the global authentification installation :
    101118
     
    155172
    156173=== Auth files and project listing ===
    157 
    158174In order to complete this setup, you will need two authentification files :
    159175
     
    211227Here you are ! Don't forget to ''chown'' these files to {{{www-data}}}, and it should work !
    212228
    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 basic
    226           AuthName "trac"
    227           AuthUserFile "/var/svn/svn-auth-file"
    228           Require valid-user
    229 </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 
    240229-------
    241230See also: TracGuide, TracInstall, TracMultipleProjectsWindows