Configure apache for multiple svn repositories

Published: {ts '2010-11-25 00:00:00'}
Author: Steven Neiland
Site Url: http://www.neiland.net/article/configure-apache-for-multiple-svn-repositories/

Setting up a apache for a SVN Repo is well documented, but only for single repositories. What if you want multiple?

Define a single repository in vhosts

In all the documentation on subversion, when the author details setting up the location of a repository they use something like this.

ServerName yourdomain.com DocumentRoot "/htdocs" Dav svn SVNPath "/svn/myrepository" ---snip---

This results in you being able to reference the repository "myrepository" by visiting the url:

http://yourdomain.com/svn/myrepository"

This works fine when you have a single repository, but what if you have several.

SVN Parent Path

Now you could simply copy and paste the Location directives for each repo....or you could use Parent Path directive. The SVNParentPath directive allows us to define the path to the parent folder in which all our repositories are located. To use it see the following example.

ServerName yourdomain.com DocumentRoot "/htdocs" Dav svn SVNListParentPath on SVNParentPath "/svn" ---snip---

Note the addition of the SVNListParentPath directive and the change from SVNPath to SVNParentPath. These changes create a root directory reference which lists all our repositories in the referenced location (provided they are all stored in the same location of course).

Accessing the repository listing is now as simple as visiting the url "http://yourdomain.com/svn/". You can then view all the listed repositories and click through to each one. The previous url for the "myrepository" repo is still valid, we just no longer have to explicitly define it in the location section.