Configuring subversion (svn) is a relatively simply matter -- until you add apache and web-dav into the mix. There're plenty of tutorials out there on the net, but none quite worked for me in getting a correctly configured system. After much playing about, I finally have it working, so I thought I would share the various steps in getting it up and running -- as well as keeping a record for myself. You know these things; you always end up doing it at least twice, and you always end up forgetting just how you managed to get it working in the first place ...
This tutorial is based on one I found on this site, with a few changes and clarifications on my part. Any problems or errors in this, please let me know!
Ubuntu's Feisty
This tutorial covers installing svn on the server edition of Ubuntu 7.04. It should equally cover the desktop edition -- I can't see why not -- but I haven't testing it.
Installing the Packages
First things first: install the appropriate packages. If you don't have an ssh sever on there, best install one first, for remote access and config:
sudo apt-get install openssh-server
Then, install all the svn and apache packages:
sudo apt-get install subversion libapache2-svn apache2
Easy peasy! The fun comes in the configuration though ...
Enabling SSL
Enable SSL, so people can't snoop on your precious code as it flies across the network:
sudo a2enmod ssl
sudo sh -c "echo 'Listen 443' >> /etc/apache2/ports.conf"
Alternatively, simply edit '/etc/apache2/ports.conf' and add the line 'Listen 443':
sudo vim /etc/apache2/ports.conf
Generating the SSL Certificate
This is what gave me the most trouble. There's a bug in Feisty that omitted the 'apache2-ssl-certificate' command from the apache2 package. I tried to generate the cert. using openssl (I know the tutorial is for Gentoo, but you would think the method the same ... ) but the generated cert would not work with Apache2.
So, in desperation, I found an installation of Debian 3.0, and ran 'apache2-ssl-certificate' there, and it worked like a charm.
sudo apache2-ssl-certificate
Fill in the bits of info that you want, but the most important thing is that you fill in your server name properly! Not doing so will cause headaches. Make sure it is the full domain name, server.domain.com, and that your '/etc/hostname' also contains the full domain name. This one gave me trouble for a while until I had all the names correctly defined.
Virtual Host
The easiest way to get Apache configured for your svn repository is to create a virtual host. Copy the default host:
sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/subversion
Then edit the file:
sudo vim /etc/apache2/sites-available/subversion
Change the entries for NameVirtualHost and VirtualHost:
NameVirtualHost *:443
<VirtualHost *:443>
Add the following lines of code just under <VirtualHost *:443>:
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.pem
SSLProtocol all
SSLCipherSuite HIGH:MEDIUM
Get Apache Running
Enable your new svn host and restart apache:
sudo a2ensite subversion
sudo /etc/init.d/apache2 restart
Setup a Subversion repository
You'll need to create a new svn repository; replace $MYREPOS with whatever name you like:
sudo mkdir /var/lib/svn
sudo svnadmin create /var/lib/svn/$MYREPOS
sudo chown -R www-data:www-data /var/lib/svn/$MYREPOS
sudo chmod -R g+ws /var/lib/svn/$MYREPOS
Link the Repository to Apache
Edit '/etc/apache2/sites-available/subversion' again:
sudo vim /etc/apache2/sites-available/subversion
And add the following lines at the end of the file, just above :
<Location /svn>
DAV svn
SVNParentPath /var/lib/svn
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/svn.passwd
Require valid-user
Require SSLRequireSSL
</Location>
Adding Users and Passwords
Now you just need to create a password file for the repository.
sudo htpasswd2 -c /etc/apache2/svn.passwd $USERNAME
For additional users, just add them in in the same way:
sudo htpasswd /etc/apache2/svn.passwd $ANOTHER_USERNAME
Restart apache -- Again
Restart Apache for all the changes to take affect:
sudo /etc/init.d/apache2 restart
Fin
And you should be done! The repository should be at 'http://server.domain.com/svn/$MYREPOS'
