How to Setup Subversion Server on Ubuntu 11.10

Subversion is an open source version control system which manages files and directories, and the changes made to them, over time. In software development environments, subversion is a tool that that fosters collaboration between programmers.

Before installing the subversion server, ensure that the Apache2 web server has been installed and properly configured. Instructions on how to do this is found here:

Install Apache2 Web Server

To install and configure a subversion server on Ubuntu Server 11.10, follow these steps:

Download and install Subversion

$ sudo apt-get update
$ sudo apt-get install subversion libapache2-svn

The libapache2-svn module is required for accessing the subversion repository using the http protocol.

Create the subversion group

$ sudo addgroup subversion
$ sudo usermod -a -G subversion {your-ubuntu-username}
$ sudo usermod -a -G subversion www-data

Add yourself and the Apache user (www-data) as users to the subversion group.

Create a folder to store the subversion repository

$ sudo mkdir /var/svn

Create the project folder and repository (e.g. if we wish to import the php project folder):

$ sudo mkdir /var/svn/php
$ sudo svnadmin create /var/svn/php

Grant web server and subversion members access

$ cd /var/svn
$ sudo chown -R www-data:subversion php
$ sudo chmod -R g+rws php

Configure Apache to access subversion

$ sudo nano /etc/apache2/mods-available/dav_svn.conf

Enter the following (or uncomment):
<Location /svn>
DAV svn
SVNParentPath /var/svn
SVNListParentPath On
AuthType Basic
AuthName “Subversion Repository”
AuthUserFile /etc/subversion/passwd
Require valid-user

SVNParentPath and SVNListParentPath enable the ability to browse all projects on the repository. For added security, consider installing the SSL module for Apache to encrypt authentication data. Require valid-user means that authentication is required to access the subversion repository.

Define a new user for accessing subversion

$ sudo htpasswd -c /etc/subversion/passwd {your-subversion-username}

Important: The -c switch should only be use for entry of the first user.

To add more users after that, use (without the -c switch):

$ sudo htpasswd /etc/subversion/passwd {another-subversion-username}

Restart the Apache web server

$ sudo service apache2 restart

Import a test project files

$ svn import -m “Initial import” /var/www/php http://hostname/svn/php/trunk

We are going to import a test project from the /var/www/php folder, and assumes that the subversion server and project file are co-located (i.e. on the same server). Create some php files in there if you don’t have any.

To confirm the project files have been imported

$ svn list http://hostname/svn/php/trunk

You should see the same set of files that are in the project folder you have imported.

That’s all! You’ve successfully setup a Subversion server on Ubuntu Server 11.10 and imported your first project.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s