Implement really simple SVN | Subversion + Apache in Debian
To implement and configure Subversion + Apache in Debian (or any other debian-based distro like Ubuntu) you need to pull some software from the Debian repositories. This guide will show you how to setup | install and configure Apache + SVN.
Preparing to install Subversion and Apache
Get a terminal, xterm should do it. Now, get Apache, subversion and DAV using the apt-get command.
$ sudo apt-get install apache2 subversion libapache2-svn sysv-rc-conf
sysv-rc-conf is not really needed for Apache + SVN installation, but it’s handy when starting/stopping server processes in Debian.
This guide is not an introduction to Subversion or version control for that matter, if you need more information about SVN, go here.
How to configure your Subversion Repository
First, choose a location, you can put it anywhere really, but I’ll put in /var/www/svnrepo, you can do this by executing the command:
$sudo mkdir /var/www/svnrepo
Change the permissions on the svnrepo folder you just created, it needs to be owned by the apache user because we will access this repo via the Apache web server. Type up the command
$sudo chown -R www-data:www-data /var/www/svnrepo
What this code means is to
- Change the ownership of the folder /var/www/svnrepo
- Make it belong to the user “www-data” (the apache user) and (this is what the colon means) group “www-data” (the apache group).
How to create a repository using svnadmin
Create the repository using the svnadmin tool, for example:
$ sudo svnadmin create /var/www/svnrepo/test
Where “test” is the name of the repository (it’s a good idea that the repo name reflects the name of the project you are working on). You need to change the permissions again, just type
$ sudo chown -R www-data:www-data /var/www/svnrepo/test
Your repo is done, now we just need to make it accessible via Apache.
How to configure Apache to serve up SVN repositories
When you pulled apache2 and libapache2-svn from the Debian repositories, one of the software it actually installed is DAV (Distributed Access and Versioning), it’s an extension of HTTP 1.1 which allows reading and writing to file systems using Internet protocols, specifically HTTP. We need to configure DAV so that apache knows where to find the SVN repo and allow access to the SVN repo.
Get an xterm, edit the file dav_svn.conf, it’s found under the /etc/apache2/mods-enabled folder.
$ sudo nano /etc/apache2/modes-enabled/dav_svn.conf
Add these lines of code:
<Location /svn>
DAV svn
SVNParentPath /var/www/svnrepo
</Location>
Using SVNParentPath means that all you project will be located under /var/www/svnrepo, if you create another svn project, say under /home/myname/newproject, the Apache will not be able to serve the svn repo from that location.
Restart apache, this is where the sysv-rc-conf will be handy, just type type up
$ sudo sysv-rc/conf
You will see an curses-based menu system which allows you to start|stop services in Debian. Just scroll down (using arrow keys) to the location of the apache2 service, then press “-” (minus sign), you might have to press enter to confirm the curses prompt — then press “+” to start the apache service again.
How to checkout a project in SVN
There are GUI clients to access SVN, TortoiseSVN from Tigris is pretty good, this link gets you to the download page of Windows version for TortoiseSVN.
To checkout a project, type:
$ svn checkout http://svn/test
Where test is the name of the repo you created a while ago using “svnadmin create”
You can use this setup for really simple repositories and if you are within a trusted domain (you know and trust everyone in the team who has access to the SVN+Apache url). You should implement even a basic ACL (Access Control List) for team grade SVN setups, see related information below for more information.
If you want to show appreciation for my efforts dear reader, you could buy me a tall hazel nut Americano ($2) via PayPal. Thanks
Leave a comment