Installing SVN and trac on Raspberry Pi

This post is step by step instructions for installing subversion (SVN) 1.8.10 and trac on the Raspberry Pi. I am writing it as a reminder to myself, but if you find it useful…

Beforehand

It’s a good idea to get up to date


sudo apt-get update
sudo apt-get upgrade

Install Subversion

First of all I checked the version included in the raspbian distribution, and I wanted a later version. I looked at using the WANdisco binaries, but found that they seemed to be missing the binaries required for the raspberry pi. So these instructions use the debian backports.
I followed these instructions. First I added wheezy-backports to me sources.list by creating /etc/apt/sources.list.d/wheezy-backports.list 

deb http://http.debian.net/debian wheezy-backports main

I tried just running sudo apt-get update, however I got the following error

W: GPG error: http://http.debian.net wheezy-backports Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 8B48AD6246925553 NO_PUBKEY 7638D0442B90D010

After a little digging I found that I could add the public keys like this

gpg --keyserver pgpkeys.mit.edu --recv-key 8B48AD6246925553
gpg -a --export 8B48AD6246925553 | sudo apt-key add -
gpg --keyserver pgpkeys.mit.edu --recv-key 7638D0442B90D010
gpg -a --export 7638D0442B90D010 | sudo apt-key add -
sudo apt-get update
sudo apt-get -t wheezy-backports install subversion

Now it is possible to update with no errors

sudo apt-get update

Finally we can install subversion

sudo apt-get -t wheezy-backports install subversion
sudo apt-get -t wheezy-backports install python-subversion

(Note: originally I missed python-subversion, this left a version mismatch and caused errors)
Now check the version installed

svn --version
svn, version 1.8.10 (r1615264)

compiled Apr 24 2015, 04:16:08 on arm-unknown-linux-gnueabihf


Copyright (C) 2014 The Apache Software Foundation.

This software consists of contributions made by many people;

see the NOTICE file for more information.

Subversion is open source software, see http://subversion.apache.org/


The following repository access (RA) modules are available:


* ra_svn : Module for accessing a repository using the svn network protocol.

– with Cyrus SASL authentication

– handles ‘svn’ scheme

* ra_local : Module for accessing a repository on local disk.

– handles ‘file’ scheme

* ra_serf : Module for accessing a repository via WebDAV protocol using serf.

– using serf 1.3.7

– handles ‘http’ scheme

Install Apache

I have decided that I am less likely to get conflicts if the versions of apace and subversion come from the same distribution. So I install from wheezy backports.

sudo apt-get -t wheezy-backports install apache2
sudo apt-get -t wheezy-backports install libapache2-svn

I got a single warning during install

Starting web server: apache2apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName

I have chosen to ignore this for now. To test the installation of apache I browsed to http://localhost/

Create Repositories

I have decided that the structure I want is to have two repositories, a play repository and a prod repository. This example just shows the creation of the play repository.
sudo mkdir /var/svn
sudo mkdir /var/svn/repos
sudo svnadmin create /var/svn/repos/play

Configure Security

I have decided to use digest access authorisation. NOTE: I am not recommending this method of securing access, but it suits my needs.
Start by editing dav_svn.conf (I use vi you could equally use nano if you prefer)
sudo vi /etc/apache2/mods-available/dav_svn.conf
The default file is all comments, and I choose to leave it intact and just append the following to the end of the file.
<Location /svn>
DAV svn
SVNParentPath /var/svn/repos
AuthType Digest
AuthName "Subversion Repo"
AuthUserFile /etc/apache2/dav_svn.htdigest
Require valid-user
</Location>
Next I need to enable digest authentication and restart apache
sudo a2enmod auth_digest
sudo service apache2 restart
Next I want to create a user in the apache/subversion digest file
sudo htdigest -c /etc/apache2/dav_svn.htdigest "Subversion Repo" david
It is important to note two things here. Firstly, if you add more than one user omit the -c on all subsequent calls as this creates the digest file and so would delete all existing users. Secondly the “Subversion Repo” argument specifies the realm and must match the AuthName in dav_svn.conf.
Now is a good time to test that it is working: browse to http://192.168.0.34/svn/play (the ip address of your RPi), you should be prompted for a username and password, enter the ones you specified when creating the digest and you should be in.
One last step is to tie down the native file access permissions, and to grant the apache user address to write to the repository.
sudo chown -R www-data:www-data /var/svn/repos

Install trac

With trac I have decided to install the version bundled with raspbian (0.12.5). I based the decision on the availability of other trac plugins, also for compatibility with subversion 1.8 I need trac >=0.12.3.
sudo apt-get install trac
sudo apt-get install lib-apache2-mod-python

Configure trac

I want trac to share the same digest authentication as subversion. I also want a separate trac database for my play and prod repositories. The steps below only show the setup for the play repository.
sudo mkdir /var/trac
sudo mkdir /var/trac/projects
sudo chown -R www-data:www-data /var/trac/projects

Edit the apache configuration

sudo vi /etc/apache2/sites-enabled/000-default

Add the following to the end of the file, just before the </VirtualHost> tag. Note that the authentication matches the subversion settings.

<Location /trac>
SetHandler mod_python
PythonInterpreter main_interpreter
PythonHandler trac.web.modpython_frontend
PythonOption TracEnvParentDir /var/trac/projects
PythonOption TracUriRoot /trac
PythonOption PYTHON_EGG_CACHE /tmp
AuthType Digest
AuthName "Subversion Repo"
AuthDigestDomain /trac
AuthDigestProvider file
AuthUserFile /etc/apache2/dav_svn.htdigest
Require valid-user
</Location>

Now it is time to create the play trac project environment

sudo -u www-data trac-admin /var/trac/projects/play initenv

You get asked a few questions, I responded play for the name of the project and accepted all other defaults.
Restart apache

sudo /etc/init.d/apache2 restart

Time to test, browse to http://192.168.0.34/trac/ (use the IP address of your RPi) you should see a list of your trac projects.

Click on the play project name and you should see trac

NOTE: According to TracAuthenticationIntroduction Note that in the current version of Trac, clicking on the logout link above the navigation bar does not logs user out because the browser still remembers the HTTP authentication and keeps sending it.

To be able to administer trac add a user as the trac admin. I use my normal trac login.

sudo -u www-data trac-admin /var/trac/projects/play permission add david TRAC_ADMIN

For further configuration to make the integration tighter and to improve performance see


Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top