Installing subversion using subdomain on Apache and Debian

Here’s a quick reference on the basics of installing Subversion on Debian using an Apache subdomain both for my own reference and others too. There were a couple of bits I had to search around for so I thought an all-in-one guide might be useful for others.

Install subversion.

apt-get install subversion

Install Apache and the SVN module for it.

apt-get install libapache2-svn apache2

Create the subversion root directory.

mkdir -p /svn

Create a repository.

svnadmin create /svn/default

Give apache rights on the root directory and its contents.

chown -R www-data:www-data /svn

Enable dav and svn modules on Apache.

a2enmod dav
a2enmod dav_svn

If you want to use a subdomain for svn like svn.example.com set up a vhost as follows.

Note: Don’t forget to replace the IP with your own.

[text]
<VirtualHost 12.34.56.78:80>
ServerAdmin webmaster@example.com
ServerName svn.example.com
ErrorLog /var/www/svn.example.com/logs/error.log
CustomLog /var/www/svn.example.com/logs/access.log combined
<Location />
DAV svn
SVNParentPath /svn
SVNListParentPath on
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /auth/svn/default/htpasswd
Require valid-user
</Location>
<Location /default>
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /auth/svn/default/htpasswd
Require valid-user
</Location>
</VirtualHost>
[/text]

Obviously configure the above to match your requirements.

Create the Apache log directory specified above.

mkdir -p /var/www/svn.example.com/logs

Give Apache rights to the log directories you’ve set up above.

chown -R www-data:www-data /var/www/svn.example.com/logs

Create a password file with your chosen username.

htpasswd -s -c /auth/svn/default/htpasswd USERNAME

Restart apache and test your setup.

/etc/init.d/apache2 restart

Note: The following configuration in the above vhost config specifies the location in the filesystem of a parent directory whose child directories are Subversion repositories.

SVNParentPath /svn

Note: And the following configuration in the above vhost config allows a GET of SVNParentPath, which results in a listing of all repositories under that path. This means that you can go to svn.example.com in your browser and see a listing of repositories underneath it.

SVNListParentPath on

That’s it. For further details see the svn book. Thanks to the excellent library article by linode.com for providing me with a concise introduction which I could adapt for my own needs. If you are not already hosting with linode.com you should be. They are the best hosting provider in the world.

Was this post helpful to you? Please let me know in the comments!

4 thoughts on “Installing subversion using subdomain on Apache and Debian

  1. I thought its illustrative purpose was adequately self explanatory and I wasn’t aware of any convention for this purpose. Besides anyone who gets confused between the two will need resources far more expansive than my guide!

  2. Bruce, I’ve made the substitution that you suggested. I went to example.com and found the following text.

    As described in RFC 2606, we maintain a number of domains such as EXAMPLE.COM and EXAMPLE.ORG for documentation purposes. These domains may be used as illustrative examples in documents without prior coordination with us. They are not available for registration.

    So I stand corrected. If IANA is indeed holding these domains for example purposes then that is a convention indeed. Thanks.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s