Subversion is a source code control system much like the older CVS (Concurrent Versioning System). Subversion (a.k.a. svn) has been designed from the ground up to be a replacement for CVS and has a number of features that CVS users can only dream of. For a while it looked like CVS might survive but Subversion has shown itself to be a worthy competitor to CVS and has begun to replace it in many high profile locations. In it's day CVS was (and still is) a fantastic piece of software and if you are currently using it and are happy with it then there are perhaps few really compelling reasons to upgrade. The most noticeable difference between CVS and Subversion is the ability to track files and directories across name changes. With CVS one has to re-add a file to change it's name for example.
I run a CVS server for my own internal development but I like to make sure I am always running the best of breed software in any particular area so I have decided to transfer over to Subversion. I do this for two reasons. Firstly, it means that I keep my skills up to date, secondly it means I am always running the best supported piece of software so when something goes wrong it's easy to get help. This article covers the upgrade process and the installation and configuration of Subversion on a Debian Etch box. I have taken the, perhaps radical, decision to abandon my CVS history when I move to Subversion. This sounds a little bold but as I am the only one that works on my code I don't consider the history as important as I do when I work with others. Many of my projects also have history that goes back far further than I am interested in.
The first step, as always, is to install the required packages. The only package the is absolutely required is subversion but I intend to run subversion over WebDAV so I will also require libapache2-svn. There is a subversion-tools package which provides a number of possibly useful scripts (for backups etc) which you might like to install as well. I have decided to access the repository over WebDAV as it provides a number of nice to have features such as compression and simple repository exploring.
Setting up Apache 2 with SSL
In order to use Subversion with WebDAV it is necessary to set up Apache 2 to use SSL. Strictly speaking it's not necessary but the link really should be encrypted. I am going to set up Apache with a host specifically for Subversion in it's own sub-domain. Login as root and open the file /etc/apache2/ports.conf add the line
To the end of the file. This will cause Apache to bind the standard HTTPS port as well as the normal HTTP port. Now create a certificate for Apache to use by running the command:
mkdir /etc/apache2/ssl make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache/ssl/apache.pem
This script will ask a number of questions most of which have no real meaning for a self-signed certificate. You should, however, fill in the common name with the name of the server that you will be using (for example "svn.example.com"). Now create a virtual host to handle your SSL enabled site. For example:
<VirtualHost 188.8.131.52:443> ServerName svn.example.com SSLEngine on SSLCertificateFile /etc/apache2/ssl/apache.pem DocumentRoot /var/www/apache2-default ServerAdmin firstname.lastname@example.org ErrorLog /var/log/apache2/error.log CustomLog /var/log/apache2/svn.example.com.log combined </VirtualHost>
Link this file into the sites-enabled directory:
ln -s ../sites-available/svn.example.com.conf 9997-svn.example.com.conf
and restart Apache. Watch for errors as Apache restarts. Note that the virtual host specifies the IP address and the port that it will be listening on. This can be used in conjunction with name based virtual hosts on the same machine.
Setting Up Subversion
I keep a directory called /data around for all the data and non-standard directories I create. For example resource for non-custom web applications and backups end up in there. It seems like a good candidate location for the subversion repository as there is not agreed upon standard location that I can find. Run the following commands as root in your /data directory (or the directory of your choosing):
su - www-data cd /data mkdir subversion svnadmin create subversion exit
This will have created an empty subversion repository owned by the user www-data. It is necessary to have www-data own the repository so that WebDAV works correctly (as this runs as the same user as the Apache). It's important not to let users run as www-data, however, as doing so would let them write files to the repository. Now we need to set up the host that will run the WebDAV access. Open the virtual host file created above (/etc/apache2/sites-enabled/svn.example.com.conf for example) and add the following:
<Location /subversion> DAV svn SVNPath /data/subversion
AuthType Basic AuthName "Subversion Repository" AuthUserFile /data/subversion/htpasswd Require valid-user </Location>
The location path is the location of repository in the current domain. The Location directive is used rather than the Directory directive because we are letting the WebDAV module control the reading and writing of the virtual file system. Now we need to add some users to the system This is done using standard htaccess.
su - www-data cd /data/subversion htpasswd -c -m htpasswd userone htpasswd -m htpasswd usertwo
Notice that I leave off the -c flag for the second and all subsequent users as we only need to create the file one. The command will ask for the password to use with each user that is created. You can now test you repository by accessing it with a URL such as https://svn.example.com/subversion. It should ask you for your user name and password and then show you a page that says something like "Revision O: /". You are now ready to start importing source into your subversion repository.
- Configure Apache SSL and Subversion in Debian in 683 seconds
- SSL + Apache2.2 + VirtualHost + Debian with automaticallyH TTPS forwarding
- The Subversion Book