Deploying trac w/ mod_wsgi
The apache config is pretty straightforward:
1 <VirtualHost *>
2 ServerName example.net
3 ServerAdmin jmoiron@example.net
4
5 DocumentRoot /var/www/example.net/
6
7 # I was moving lots of stuff from '/tracenv' to '/trac/tracenv', and had
8 # 4 or so lines of redirect matches; broken URLs are bad!
9 RedirectMatch permanent ^/projects/(.*) http://dev.jmoiron.net/trac/projects/$1
10 ...
11
12 # similarly, I had some modified htdocs
13 Alias /trac/projects/chrome/common/ /home/jmoiron/var/htdocs/trac/
14 ...
15
16 # allow access to the htdocs...
17 <Directory "/home/jmoiron/var/htdocs/trac/">
18 Options Indexes MultiViews FollowSymlinks
19 AllowOverride None
20 Order allow,deny
21 Allow from all
22 </Directory>
23
24 # trac wsgi script; you might want to make this outside of
25 # any <Directory> directives you have so it doesn't leak out
26 WSGIScriptAlias /trac /home/jmoiron/var/trac/wsgi/trac.wsgi
27 <Directory "/home/jmoiron/var/trac/wsgi">
28 WSGIApplicationGroup %{GLOBAL}
29 Order deny,allow
30 Allow from all
31 </Directory>
32
33 # handle HTTP auth for all trac environments at once
34 <LocationMatch "/trac/.+/login">
35 AuthType Basic
36 AuthName "trac"
37 AuthUserFile /home/jmoiron/path/to/htpasswd
38 Require valid-user
39 </LocationMatch>
40
41 ...
42 </VirtualHost>
Few notes on above:
trac.wsgi handles the environ] page itself, so no duplication of directives with different TracEnv variables like the cgi version
I simplified my setup a lot with the LocationMatch directive; in my previous conf I had all of the paths kinda jammed into using the exact same location
the normal htdocs are in /usr/share/pyshared/trac/htdocs
The trac.wsgi file is pretty simple and _almost_ straight off their docs:
1 #!/usr/bin/env python
2
3 import os
4
5 # here's the difference to get the 1 parent trac env directory
6 os.environ['TRAC_ENV_PARENT_DIR'] = '/home/jmoiron/var/trac/'
7 os.environ['PYTHON_EGG_CACHE'] = '/home/jmoiron/var/trac/eggs/'
8
9 import trac.web.main
10 application = trac.web.main.dispatch_request
Upgrading Trac
Upgrading trac was fairly simple; a few steps had to be taken:
editing trac/<tracenv>/conf/trac.ini to point to the new urls & new svn locations
trac-admin <tracenv> upgrade
trac-admin <tracenv> wiki upgrade (this upgrades the base wiki help)
trac-admin <tracenv> resync (resyncs trac environment w/ new svn locations)
.