Setting up subversion for multiple repositories on a Plesk/Ubuntu VServer

Setting up a SVN server on an Ubuntu Vserver running Plesk is smooth like butter. Mmmh, butter… Just for future reference, i’m going to explain it here.

Update: Configuration of basic authentication is included now.

First, install subversion and the Apache library with the command

sudo apt-get install subversion libapache2-svn

Next, enter the Subversion/Apache configuration into the vhost.conf file of the respective domain, e.g. /var/www/vhosts/[DOMAIN NAME]/conf/vhost.conf. This file contains all the important Apache stuff for the subdomain.

<Location /svn>
DAV svn
SVNParentPath /var/www/vhosts/[DOMAIN NAME]/svn
# The following three lines allow anonymous read, but make
# committers authenticate themselves.
<LimitExcept GET PROPFIND OPTIONS REPORT>
AuthType Basic
AuthName "SVN Authorization Realm"
AuthUserFile /var/www/vhosts/[DOMAIN NAME]/svn/svnAuthUsers.passwd
Require valid-user
</LimitExcept>
</Location >

What is left is to create an example repository, restart Apache

cd /var/www/vhosts/[DOMAIN NAME]
mkdir svn
svnadmin create svn/test
chown -R www-data:www-data svn/
sudo /etc/init.d/apache2 restart

and to test it from your home computer

svn co http://www.[DOMAIN NAME]/svn/test

To allow you – and only you – to commit new files, authentication has to be configured. Run the following command on the the server, using your local user name for convenience:

htpasswd -c /var/www/vhosts/[DOMAIN NAME]/svn/svnAuthUsers.passwd [USERNAME]

You will be prompted for a password. Commiting new files and directories should work now as well. And that’s pretty much it!

To allow only authenticated users to checkout the repository, remove both lines containing the “LimitExcept” from the vhost.conf file. Another excellent explanation of the setup process is to be found here.

10 Responses to “Setting up subversion for multiple repositories on a Plesk/Ubuntu VServer”

  1. one correction, I think you meant:

    svnadmin create var/www/vhosts/[DOMAIN NAME]/svn/test

    (instead of svn)

  2. Sure did! Thanks for pointing out that mistake.

  3. Nice clear instructions thankyou!!! (note: I have a slightly different setup where instead of the vhosts file I had to change the file /etc/apache2/sites-available/[DOMAIN NAME].conf) but everything turned out perfectly.

  4. thx! That was exactly what I’ve been lookin for.

  5. Really nice tutorial.

    First it didn’t worked, but than I found out, that ich have to run:
    /usr/local/psa/admin/bin/websrvmng -a -v
    before restarting the apache. After that it worked. Maybe this is a usefull information for someone…

  6. Another correction, in fact I’m not sure how it worked for anyone else:

    You have on one line:

    AuthUserFile /var/www/vhosts/[DOMAIN NAME]/svn/svnUsers.passwd

    But then you have:
    htpasswd -c /var/www/vhosts/[DOMAIN NAME]/svn/svnAuthUsers.passwd [USERNAME]

    svnUsers.passwd != svnAuthUsers.passwd

    Kept overlooking it until I looked at the error logs!

  7. True, I must have overlooked it while copying the lines. I’ve corrected the post, sorry. I guess the svn checkout and update works anyways.

  8. Perfect piece of work you have done, this website is really cool with good info .

  9. Love the tutorial, However what if you want all your sites in let’s say:

    /var/www/[DOMAIN]

    and all repositories within:

    /var/svn/[DOMAIN]

    And access this via the web/tortoise?

  10. I am not sure but I guess this should be possible if directory owners and access rights are set properly.