Subversion Install Swankiness Part I

Here we go with the newly decided first part of my Subversion install series.  I decided to break it up into smaller chunks of articles as the first part really is the installation/setup part and the second is the integration/deploying part.  So with this first part we’re gonna talk about downloading, verification, repository setup, and Apache integration.  I’ll make it short and sweet as possible but grab a cup of joe so we can get started.

When figuring out how I should download Subversion, I weighed many options.  I could either grab the source from their website at Tigris or install from Ubuntu’s repository.  The hardcore geek in me wanted to compile from source, but I really wanted to roll out the software quick so I can focus on the blog code.  Also  updates trickle down from Ubuntu with relative automation, so I went with acquiring the binary from Ubuntu.  It really makes sense to knock out the binaries for tools surrounding a project and focus on source for project related code.  Why waste your time setting up a utility when it’s the poject you should be working on?

After some research, I decided to follow the steps provided by How-To Geek.  I updated my repository and installed Subversion.  After the packages were downloaded, unpacked, and installed, I verified that it had indeed been setup on my system.  Here’s how it happened:

hokey@tardis:~$ sudo apt-get install subversion
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libneon26 libsvn1
Suggested packages:
subversion-tools db4.4-util
The following NEW packages will be installed:
libneon26 libsvn1 subversion
0 upgraded, 3 newly installed, 0 to remove and 3 not upgraded.
Need to get 964kB of archives.
After unpacking 5128kB of additional disk space will be used.
Do you want to continue [Y/n]?

hokey@tardis:~$ svn --version
svn, version 1.4.4 (r25188)
compiled Sep 28 2007, 10:50:44

Copyright (C) 2000-2006 CollabNet.
Subversion is open source software, see http://subversion.tigris.org/
This product includes software developed by CollabNet (http://www.Collab.Net/).

The following repository access (RA) modules are available:

* ra_dav : Module for accessing a repository via WebDAV (DeltaV) protocol.
- handles 'http' scheme
- handles 'https' scheme
* ra_svn : Module for accessing a repository using the svn network protocol.
- handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
- handles 'file' scheme

So after verification it was time to decide on where to create my new repository and setup web access.  Now with anything Linux-wise, you are pretty much left to your own notions as to where to drop a directory for installs.  Companies like Adobe use /opt for their application installs and some programs use /var to store data separate from program files. I figured /var/svn was reasonable enough so I had at it, creating the directory and using the Subversion command create to setup the files:

hokey@tardis:/var$ sudo mkdir svn

hokey@tardis:/var$ sudo svnadmin create /var/svn/

hokey@tardis:/var$ cd svn
hokey@tardis:/var/svn$ ls -lat
total 36
drwxr-xr-x 7 root root 4096 2008-11-07 17:54 .
drwxr-xr-x 2 root root 4096 2008-11-07 17:54 conf
drwxr-xr-x 2 root root 4096 2008-11-07 17:54 dav
drwxr-sr-x 5 root root 4096 2008-11-07 17:54 db
-r--r--r-- 1 root root 2 2008-11-07 17:54 format
drwxr-xr-x 2 root root 4096 2008-11-07 17:54 hooks
drwxr-xr-x 2 root root 4096 2008-11-07 17:54 locks
-rw-r--r-- 1 root root 229 2008-11-07 17:54 README.txt
drwxr-xr-x 15 root root 4096 2008-11-07 17:47 ..

Now that the repository was created, I needed to figure out how to get web access up. Welp, thanks to the How-To Geek and the original coders of the module, there was one available to tie it all together. Using libapache2_svn, a client can connect via Apache to a Subversion repository and write to it using DAV. This was a perfect setup, even though the security isn’t the greatest, for me to develop locally before deploying my sites to my host. So here’s how I did it:

hokey@tardis:/etc/apache2/mods-available$ sudo apt-get install libapache2-svn
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
db4.4-util
The following NEW packages will be installed:
libapache2-svn
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 136kB of archives.
After unpacking 344kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com gutsy/main libapache2-svn 1.4.4dfsg1-1ubuntu3 [136kB]
Fetched 136kB in 1s (126kB/s)
Selecting previously deselected package libapache2-svn.
(Reading database ... 30761 files and directories currently installed.)
Unpacking libapache2-svn (from .../libapache2-svn_1.4.4dfsg1-1ubuntu3_i386.deb) ...
Setting up libapache2-svn (1.4.4dfsg1-1ubuntu3) ...
Enabling dav as a dependency
Module dav installed; run /etc/init.d/apache2 force-reload to enable.
Module dav_svn installed; run /etc/init.d/apache2 force-reload to enable.

After I installed the module, I had to edit the dav_svn.conf file to point to my settings. Following the instructions, I removed the comments for configuration which included:

  • Setting the repository location:Location /var/svn
  • Uncommenting DAV svn
  • Setting the SVNPath: SVNPath /var/svn
  • And ucommenting the authority settings:
    AuthType Basic
    AuthName "Subversion Repository"
    AuthUserFile XXXXXX
    Require valid-user

I then setup the authentication:
hokey@tardis:/etc/apache2/mods-enabled$sudo htpasswd -cm /etc/apache2/dav_svn.passwd hokey
New password:
Re-type new password:
Adding password for user hokey

After doing a quick restart: hokey@tardis:/etc/apache2/mods-enabled$ sudo apache2ctl restart, I got this:

The wrong Location
The wrong Location

What was wrong? I set the Location for Apache as /var/svn. What I was shooting for was to have /svn as the root. Doh!  The SVNPath already tells Apache where to look for the repository. The Location tag and attribute in the configuration tell Apache where to display it on the web server. So I made the change and restarted. After testing authentication, I was ready to rock. Stay tuned for Part 2 of my swankiness as I look to integrate Subversion with a project and deploy it back to my host.