Creating a WebDAV-accessible SubVersion repository using Apache

Creating a Subversion repository through HTTP using the WebDAV protocol isn't that hard. But remembering the necessary steps is.

In order to create a repository you need to follow these steps (do it with sudo or in a root shell):

Install the needed packages:

  • subversion
  • libapache2-svn

Create a virtual host in Apache2 and point it to /home/svn. Configuration sniplet:

  <Location /faq>
    DAV svn
    SVNPath /home/svn/faq
    AuthType Basic
    AuthName "Documentation Team Repository"
    AuthUserFile /etc/subversion/passwd
    <LimitExcept GET PROPFIND OPTIONS REPORT>
      Require valid-user
    </LimitExcept>
  </Location>

(Important: Don't use a DocumentRoot setting for this virtual host!)

Restart apache (if needed):

 /etc/init.d/apache2 reload

Create the repository:

 svnadmin create /home/svn/faq

Create a password file:

 htpasswd2 -c /etc/subversion/passwd [username]

Try accessing it:

 lynx http://server/faq

(You will not be prompted for credentials. That's normal.)

Try to check out the file:

 svn co http://server/faq

Voila. The repository is set up.

SubVersion for repository users

To checkout (=download) the files in the repository for the very first time run this command::

 svn co http://server/faq

Don't worry about other people working on the same files. Just do your changes to the files and when you seem to have a stable state (make sure everything works well enough so not everything will break for others) you should check in your work::

 svn ci

(Only when committing your changes you will be prompted for your username and password.)

Run the following command regularly to get the changes from other contributors::

 svn update

If you want to add new files to the repository::

 svn add [filename]

To get a status of which files have changed::

 svn stat

SubVersion for local repositories

This type of installation is used when you want subversion to track your local files but don't want/need to put it on a host. You can create a local repository and access it directly. This repository is not password protected and it's permissions depend on the filesystem's permissions.

Install the needed packages (as root or with sudo):

 apt-get install subversion

Create the repository (with your user):

 svnadmin create /home/joe/repositorie

The url to your repository is it's path preceeded with file://. For example to checkout you would do the following:

Don't forget to make the repository accessible for your web server:

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

 svn co file:///home/joe/repositorie

Resources