Setting up SVN with Trac on a web server
June 21st, 2007 by Leons PetrazickisTrac is an excellent web-based wrapper for SVN that adds bug tracking, a wiki, and several handy project management features. I keep setting up new repositories up for all the little projects we cook up in DB2 Technical Marketing, so I thought I’d write up a guide.
Installing Trac, SVN, and dav_svn for Apache2 is left as an exercise for the reader.
Create a new SVN repository:
Create a new Trac environment:
Change the owner to Apache so that it can read and write:
chown -R www-data Project
cd ../trac
chown -R www-data Project
Navigate to Apache site settings:
If you want Trac to support multiple repositories, edit the trac file to look like this:
ServerAdmin me@somewhere.com
ServerName mysite.com
DocumentRoot /usr/share/trac/cgi-bin/
<Directory /usr/share/trac/cgi-bin/>
Options Indexes FollowSymLinks MultiViews ExecCGI
AllowOverride All
Order allow,deny
allow from all
</Directory>
Alias /var/trac/chrome/common /usr/share/trac/htdocs
<Directory "/usr/share/trac/htdocs">
Order allow,deny
Allow from all
</Directory>
Alias /trac "/usr/share/trac/htdocs"
<Location /trac.cgi>
SetEnv TRAC_ENV_PARENT_DIR "/var/trac"
</Location>
<LocationMatch "/trac.cgi/[^/]+/login">
AuthType Basic
AuthName "Trac"
AuthUserFile /etc/apache2/trac.passwd
Require valid-user
</LocationMatch>
DirectoryIndex trac.cgi
ErrorLog /var/log/apache2/error.trac.log
CustomLog /var/log/apache2/access.trac.log combined
</VirtualHost>
The above assumes that all the repositories are in /var/trac
Navigate to Apache settings:
Append to dav_svn.conf:
DAV svn
SVNPath /var/svn/Project
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.passwd
AuthzSVNAccessFile /etc/apache2/dav_svn.authz
<LimitExcept GET PROPFIND OPTIONS REPORT>
Require valid-user
</LimitExcept>
</Location>
The above lets you check out from http://yoursite/svn/Project
If you like, you can add a new user to dav_svn.psswd:
htpasswd2 /etc/apache2/dav_svn.passwd NewUser
Users can then be granted permissions by editing the dav_svn.authz file. Sample file:
developers = NewUser, OtherUser
others = ThirdUser
# Restrictions on the entire repository.
[/]
# Anyone can read.
* = r
# Developers can change anything.
@developers = rw
# Other can write here
[/trunk/public/images]
@others = rw
[/trunk/public/stylesheets]
@others = rw
Restart Apache:
killall apache2 apache2
You now have have an Trac/SVN install with SVN at http://yoursite/svn/Project and Trac at http://yoursite/trac.cgi
Posted in unix |



