The Cunning Plan
One of the planned functionality for my new silent server was to offer a Subversion repository for code and documents that I could access via WebDAV. By doing this, I would be able to save important documents on the server and benefit from version control. Version control is essential for computer code but can also be very useful for other types of documents by allowing you to have multiple versions, revert to an old version, etc. So without further ado, let's get into the nitty gritty of getting it to work on Ubuntu 7.10.
- Version Control with Subversion, the book about Subversion, which you can download for free,
- Install Subversion with Web Access on Ubuntu by the How-To Geek.
Installing the software packages
We need to install Subversion, Apache and the Subversion libraries for Apache. As this is all part of the standard Ubuntu distribution, it is extremely easy.
sudo apt-get install subversion apache2 libapache2-svn
And that's it, you have a working Subversion installation! It doesn't do very much yet so we need to create repositories for documents.
Subversion is extremely flexible in the way it deals with files and directories. There are a number of standard repository layout that are well explained in the book. Then there's the question of whether you'd rather put everything in the same repository or split it. This is also well explained in the book. My rule of thumb is to only create multiple repositories if you need to keep things completely separate, such as having one repository per customer, or if you need different settings. In my case, I need to store code and documents, the code being accessed via an IDE that competely supports Subversion, the documents being accessed as a network folder. Both usage scenarios require different settings in Apache so this is a typical case where several repositories are a good idea. However, there is no need for splitting the code or the document repositories further. You can create your repositories where you want in the file system, I chose to create them in a specific top level directory.
$ sudo mkdir /svn $ sudo svnadmin create /svn/docs $ sudo svnadmin create /svn/dev $ sudo chown -R www-data:www-data /svn/*
svnadmin command created a complete structure:
ls /svn/dev conf dav db format hooks locks README.txt
The last command changes ownership recursively of both repositories so that the Apache instance can read and write to them. This is essential to get WebDAV to work.
Next, we need to configure Apache so that it can provide access to both repositories over WebDAV.
$ cd /etc/apache2/mods-available $ sudo vi dav_svn.conf
In this file, I defined two Apache locations, one for each repository, with slightly different options. As this is a home installation, I don't need authentication. If you want to add authentication on top, check the How-To Geek article. The extra two options on the documents location are meant to enable network clients that don't support version control to store files. See Appendix C of the Subversion book for more details. Note that if you wanted to use several development repositories, such as one for each of your customers, you could replace the
SVNPath option with
SVNParentPath and point it to the parent directory.
<Location /dev> DAV svn SVNPath /svn/dev </Location> <Location /docs> DAV svn SVNPath /svn/docs SVNAutoversioning on ModMimeUsePathInfo on </Location>
The last thing to do is to restart Apache:
$ sudo /etc/init.d/apache2 restart
Now that the Subversion server is working, it's time to connect to it using client software. For development, I use Eclipse for which there is the Subclipe plugin. It all works as expected. For the documents repository, Apple OS-X has built-in support for WebDAV remote folders. Go to the finder, select the menu Go > Connect to Server and type in the folder's URL in the dialogue box that appears, in my case
http://szczecin.home/docs. It's also possible to browse both repositories using a web browser, which is a good way to provide read-only access.
That was a very short introduction to Subversion on Ubuntu. There's a lot more than this to it, a lot of it in the Subversion book. In particular, you can add authentication and SSL to the repositories once they are available through WebDAV. There are also a lot of options as far as Subversion clients are concerned and you can find free client software for every operating system you can think of.