Create the SVN Repository

All of my SVN repositories were located at /var/my-svn-reps. So when I wasnted to create one more for remote (over the internet) access, the most logical thing to do was to create another one under the same directory. However, realized later that, that might not be a great idea. Since this repository, and others like it I might create, will hang off the internet it is best to locate them outside of this folder structure. So created another regular folder called public inside of this repository folder and then used svnadmin create <repo_name> to create a repository inside this public folder.

Repository listing

root@ub1:/var/my-svn-reps/public# ls -l
total 4
drwxr-xr-x 7 www-data www-data 4096 2009-08-07 22:39 svn-docs

Note that the owner:group is set to apache user

Configure Apache

Added the following configuration to apache:

        <Location />
          DAV svn
          SVNListParentPath On
          SVNParentPath /var/my-svn-reps/public
          AuthType Basic
          AuthName "Subversion repository"
          AuthUserFile /xyz/abc/htpasswd_files/svn.htpasswd
          Require valid-user
        </Location>

This block is inside an almost regular VirtualHost block. The rest of the virtual host block do the neccessary setup for a https enabled subdomain which will be my repository URL.

Here are some additional explanation of the block itself

  • Location - This is the virutual location coming after the (https) URL
  • DAV svn - I guess svn runs off of DAV and this line is required for that
  • SVNListParentPath On - This will allow all SVN repositories under the SVNParentPath to be listed. This is why we created the public folder or it will list all repositories in that path and we don't want them all internet enabled.
  • SVNParentPath - as explained above
  • Auth lines - these are regular apache authentication. In this case we are not any fine grained SVN auth.

Here is the full virtual block:

<VirtualHost *:443>
        SSLEngine On
        SSLCertificateFile /etc/apache2/ssl/server.crt
        SSLCertificateKeyFile /etc/apache2/ssl/server.key

        ServerName svn-repo.example.org
        ServerAdmin webmaster@example.org

        <Location />
          DAV svn
          SVNListParentPath On
          SVNParentPath /var/my-svn-reps/public
          AuthType Basic
          AuthName "Subversion repository"
          AuthUserFile /xyz/abc/htpasswd_files/svn.htpasswd
          Require valid-user
        </Location>

        ErrorLog /var/log/apache2/error_svn-repo.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/access_svn-repo.log combined
        ServerSignature On

</VirtualHost>

Some of the items here are:

  • Set the virutal host (sub)domain details
  • Set up the AuthUserFile

Using it

Checkout the working copy using the url: https://svn-repo.example.org/svn-docs


QR Code
QR Code tech:svn:svn_repository_using_apache (generated for current page)