|Version 5 (modified by 17 years ago) ( diff ),|
Global – Microsoft Windows Setup
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 procedure is based on the original procedure provided by the Trac team and the Initial install instructions at TracOnWindows.
Note: *nix based directory references may not work for all settings. Often times a *nix relative or absolute reference needs to be replace with the drive letter and path for it to work in a Windows environment. Often times this can solve problems.
Default install drive C:
Directories as set in TracOnWindows install guide
Configured not using a Virtual Host directive (am working on instructions for use of Virtual Host)
Start out by creating a
projects directory in your Document Root (C:/Program Files/Apache Group/Apache2/htdocs in this example). Projects will be accessed as http://hostname/projects/projectname. Create a directory in htdocs called,
projects. Copy trac.cgi to this
projects/ directory together with a file named index.html (create if needed). This will be shown when users try to access nonexistent projects.
Next create your Trac projects with trac-admin. In the original *nix multiple repositories install instructions the Trac projects need to reside in the same directory. The reference to the directory is the physical path, In this example we'll use
Note: if you are following the Trac install your database will be named "something.db" that ".db" is important. Where you set the TRAC_ENV below you will need to add that extenstion to have in find the database correctly.
Add the following to your Apache configuration:
# RewriteCond removed at the moment since not needed # Notice paths are physical location on hard drives RewriteEngine on # Log settings uncomment these lines if you are having issues. # RewriteLogLevel go from 0 to 9. 0 being off. Refer to Apache Docs on this # RewriteLog should is physical location of log file # RewriteLogLevel 9 # RewriteLog "C:/Program Files/Apache Group/Apache2/logs/rewrite.log" RewriteRule ^/projects/+$ /projects/index.html [L] #RewriteCond /var/lib/trac/$1 -d # following rule check TRAC_ENV, after $1 you may need to add '.db' if based on Trac install RewriteRule ^/projects/([[:alnum:]]+)(/?.*) /projects/trac.cgi$2 [S=1,E=TRAC_ENV:c:/svn/$1] RewriteRule ^/projects/(.*) /projects/index.html Alias /trac "C:/Python23/share/trac/htdocs" #or where you installed the trac htdocs #You have to allow people to read the files in htdocs <Directory "C:/Program Files/Apache Group/Apache2/htdocs/projects/"> AllowOverride None Options ExecCGI -MultiViews +SymLinksIfOwnerMatch AddHandler cgi-script cgi Order allow,deny Allow from all </Directory> <LocationMatch "/projects/[[:alnum:]]+/login"> AuthType Basic AuthName "trac" AuthUserFile /path/to/trac.htpasswd Require valid-user </LocationMatch>
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.
Suggestion: In the second RewriteRule directive and in the LocationMatch directive, change
[^/] 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:]\-], which matches only an alphanumeric character or a hyphen (the backslash "escapes" the hyphen, which would otherwise have special meaning). The 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.