WebSVN Server

The following will assume that you have a working SVN server up and running.  Check out my Subversion server with LDAP authentication doc for info on how to install subversion.  Now, on to WebSVN.

  1. Download the source code for WebSVN from http://websvn.tigris.org/files/documents/1380/45610/websvn-2.2.0.tar.gz
  2. Unpack the source code using:
    # tar -xzf websvn-2.2.0.tar.gz
  3. Change to the websvn directory
    # cd websvn-2.2.0
  4. As you will see all the files are ready to be copied to your web server location.
    # mkdir /srv/www/vhosts/svn.example.com/http/websvn
    # cp -a . /srv/www/vhost.d/svn.example.com/http/websvn/
    # chown -R wwwrun:www /srv/www/vhosts/svn.example.com/http/websvn
  5. Because we are doing mixed authentication and anonymous svn repositories I will copy the files to htts for ssl authencation (more on this in a bit)
    # mkdir /srv/www/vhosts/svn.example.com/https/websvn
    # cp -a . /srv/www/vhost.d/svn.example.com/https/websvn/
    # chown -R wwwrun:www /srv/www/vhosts/svn.example.com/https/websvn
  6. No we need to make some changes to the apache config.  First let's create a websvn.conf file
    # vi /etc/apache2/custom/websvn.conf.  This will be similar to your subversion.conf

    <Location />
    Order deny,allow
    Deny from all
    AuthName "UBCO SVN Repositories"
    AuthType Basic
    AuthBasicProvider ldap
    AuthzLDAPAuthoritative Off
    AuthLDAPUrl ldap://ldap.example.com:389/o=ouc?uid?sub?(objectClass=posixAccount)
    Satisfy Any
    Require valid-user
    </Location>

  7. Next we are going to modify our existing subversion vhosts files.  First we will edit the svn.example.com file
    # vi /etc/apache2/vhosts.d/svn.example.com.conf
    Add the following information in the <Directory> declaration for your http folder

    Options  Indexes FollowSymLinks Multiviews         (note that we are just adding Multiviews here)
    DirectoryIndex wsvn.php

  8. Now let's modify our SSL vhost file:
    # vi /etc/apache2/vhosts.d/svn.example.com-ssl.conf
    Add the following information in the <Directory> declaration for you http folder (identical to the http info)

    Options  Indexes FollowSymLinks Multiviews         (note that we are just adding Multiviews here)
    DirectoryIndex wsvn.php

    We also need to include our websvn.conf file for authentication within the <VirtualHost> declaration

    Include /etc/apache2/custom/websvn.conf

  9. Next let's copy the wsvn.php file to the root of our svn virtual host (this is optional but I like it)
    # cp /srv/www/vhosts/svn.example.com/http/websvn/wsvn.php /srv/www/vhosts/svn.example.com/http/
    # cp /srv/www/vhosts/svn.example.com/https/websvn/wsvn.php /srv/www/vhosts/svn.example.com/https/
  10. Now create the config.php file for websvn.php with the settings you like
    # cp /srv/www/vhosts/svn.example.com/http/websvn/include/distconfig.php /srv/www/vhosts/svn.example.com/http/websvn/include/config.php
    # cp /srv/www/vhosts/svn.example.com/https/websvn/include/distconfig.php /srv/www/vhosts/svn.example.com/https/websvn/include/config.php

    Here are list of changes that I made to the dist file (the changes are identical in both http and https)
    $config->parentPath('/srv/svn/repositories');
    $config->useMultiViews();
    $config->useAuthenticationFile('/etc/apache2/custom/svn.access'); // Global access file
    $config->allowDownload();
    $config->setDefaultFileDlMode('plain');
    $config->setDefaultFolderDlMode('gzip');
    $config->setTarballTmpDir('temp');
    $config->setMinDownloadLevel(0);
    $config->useEnscript();

  11. Now it is time to reload apache with the new settings to test it out
    # rcapache2 reload
  12. If you need to modify the template page modify the following file in the websvn directory: template/calm/index.tmpl
  13. This will allow http://svn.ok.ubc.ca to point to all anonymously accessible svn repositories and https://svn.ok.ubc.ca will point to all anonymous and user restricted repositories the authenticated user has access to.

Leave a Reply