HOW-TO Install Subversion on Ubuntu using Apache in 10 steps

A few weeks ago I wrote an article on how to install Subversion and Apache in a Windows environment. Today I decided to use Ubuntu as my development environment and somehow I felt that it would take many more steps to configure those in Linux than it took in Windows, so I wrote them down for future reference. Here are those steps:
1. Install apache2

dambrosio@Sepultura:~$ sudo apt-get install apache2


2. Test apache2 installation

dambrosio@Sepultura:~$ curl localhost
<html><body><h1>It works!</h1>
<p>This is the default web page for this server.</p>
<p>The web server software is running but no content has been added, yet.</p>
</body></html>


3. Install subversion along with its apache modules

dambrosio@Sepultura:~$ sudo apt-get install subversion libapache2-svn


The above command should already install the mod_dav subversion module, which allows apache and subversion to use WebDAV to exchange files over HTTP protocol. You can check if it has been installed using the following command:
4. Check (or install) WebDAV subersion's apache modules

dambrosio@Sepultura:~$ sudo a2enmod dav_svn
Considering dependency dav for dav_svn:
Module dav already enabled
Module dav_svn already enabled


If it not there, install the module and use the above command again to enable it.

dambrosio@Sepultura:~$ sudo apt-get install libapache-mod-dav apache2


5. Create the subversion repository

dambrosio@Sepultura:~$ sudo mkdir /var/svn
dambrosio@Sepultura:~$ sudo mkdir /var/svn/repository
dambrosio@Sepultura:~$ sudo svnadmin create /var/svn/repository


6. Now make apache the owner of the repository and give it write access

dambrosio@Sepultura:~$ sudo chown www-data:www-data -R /var/svn/repository
dambrosio@Sepultura:~$ sudo chmod -R g+ws /var/svn/repository/


7. Configure the mod_dav

dambrosio@Sepultura:~$ sudo vi /etc/apache2/mods-available/dav_svn.conf


You should have at least these settings in your file. They are all commented out by default, so uncomment them and change wherever you feel necessary, like the SVNParentPath, for instance.

<Location /svn>
  DAV svn
  #SVNPath /var/svn/repository - keep this commented to enable  the Path to a specific repository
  SVNParentPath /var/svn

  AuthType Basic
  AuthName "Subversion Repository"
  AuthUserFile /etc/apache2/dav_svn.passwd

</Location>


8. Restart apache so the configurations take effect

dambrosio@Sepultura:~$ sudo /etc/init.d/apache2 restart


9. Validate that you have access to the repository

dambrosio@Sepultura:~$ curl http://localhost/svn/repository/


10. Add the basic authentication

dambrosio@Sepultura:~$ sudo htpasswd -c -m /etc/apache2/dav_svn.passwd dambrosio


Of course you can (must) always check the SVN Book, but I hope that this HOW-TO was useful in saving you folks some googling.
Cheers!