Subversion: Repository on Subdomain

This is a tutorial on how to setup a Subversion repository on a subdomain with Apache. This assumes you have Subversion and Apache already installed on your system.

Subversion Setup

First you need to create a repository somewhere in your file system. Then grant apache permissions on that directory.

svnadmin create /var/svn/repository
sudo chown -R www-data:www-data /var/svn/repository

Controlling Access

Access to the repo via the web will be controlled by an htpasswd file located at /var/svn/svn-auth-file. Use the htpasswd command to create the file.

htpasswd -c /var/svn/svn-auth-file <username>

Execute the script again without the -c argument to add more people to the list.

htpasswd /var/svn/svn-auth-file <username_two>

Apache Setup

I usually setup Apache to use Names VirtualHosts to handle multiple websites. We’ll make a new named virtualhost for subversion repository.

<VirtualHost *:80>
<location />
DAV svn
SVNPath /var/svn/repository

AuthType Basic
AuthName "Subversion repository"
AuthUserFile /var/svn/svn-auth-file
Require valid-user