Edgewall Software

Changes between Version 31 and Version 32 of TracMultipleProjects


Ignore:
Timestamp:
Feb 18, 2005, 4:40:17 PM (19 years ago)
Author:
sam
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • TracMultipleProjects

    v31 v32  
    11= Configure Apache for multiple projects =
    22
    3 By following these instructions, you will set up Apache to automatically serve multiple Trac projects for you.
     3By following these instructions, you will set up Apache to automatically serve multiple Trac projects for you. There is two different ways of setting this up : with and without global authentification.
    44
    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.
     5== URL Rewriting ==
    66
    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:
     7Both ways use Apache's URL rewriting module : {{{mod_rewrite}}}. You have to make sure you have it loaded or compiled in Apache.
     8
     9=== Apache 1.x ===
     10
     11In 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}}} :
     12
     13{{{
     14LoadModule rewrite_module modules/mod_rewrite.so
     15}}}
     16
     17=== Apache 2.x ===
     18
     19Newer 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 :
     20
     21{{{
     22cd /etc/apache2/mods-enabled/
     23ln -s ../mods-available/rewrite.load .
     24}}}
     25
     26Don't forget to check that the {{{LoadModule}}} line in this file is uncommented :
     27
     28{{{
     29LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
     30}}}
     31
     32== Global ==
     33
     34This 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.
     35
     36Start out by creating a {{{projects}}} 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 {{{projects/}}} directory together with a file named index.html. This will be shown when users try to access nonexistent projects.
     37
     38Then 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:
    839
    940{{{
     
    4172}}}
    4273
    43 Make sure you have the rewrite module loaded or compiled in Apache.
    44 
    45 {{{LoadModule rewrite_module modules/mod_rewrite.so}}}
    46 
    4774Now, 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.
    4875
     
    5178'''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.
    5279
     80== Per-project ==
    5381
    5482----