Wednesday, December 2, 2009

Setting up DAV SVN on Apache

I had to set up another SVN dav for a client today, but I have to admit that I don't do this every day. I use svn for my own stuff, but its been a while since I last set this up. Here are the steps I follow

1. Decide if this location will be a single svn dav or will there be multiple repos. If you host many projects under one dav, then you will get version numbers that are shared and increment with any change. I had this happen to me at Bluefly - its not the end of the world, but it can be a little annoying.

2. Create the folder and then the repo with

svnadmin create /folder/repo

Again, if you were to make your dav had multiple repos, you might just create /folder/repos and then do

svnadmin create /folder/repos/repo-1

3. I'm guessing you aren't going to leave your repo to just anyone, so go ahead and create an htpasswd file to at least secure PUT requests.

htpasswd -bc .svnaccess-file svn-user s3cr3tPwd

4. Modify your apache config. I bet you could do this in an .htaccess file, but I didn't try that yet.


    <Directory "/folder/repo">
       Options Indexes FollowSymLinks
       Order allow,deny
       Allow from all
    </Directory>
    <Location /svn-repo>
     DAV svn
    # This is for a single repo
     SVNPath /folder/repo

     # Limit write permission to list of valid users.
     <Limit GET PUT PROPFIND OPTIONS REPORT>
        AuthType Basic
        AuthBasicProvider file
        AuthUserFile /home/axiomgroup/.svnaccess
        AuthName "Log into the SVN Repo"
        require user svn-user
     </Limit>
    </Location>


That's about it. If you don't secure PUT, then you won't know who made the repo changes. If you remove GET from the Limit option, then your repo will be open to anyone to downlaod from.

If you were to put multiple repos under this one DAV location, then you would want to use SVNParentPath over SVNPath

No comments: