2016-12-31

Installing a Subversion server on a (new) Raspberry Pi, Apache 2.4


Installing a Subversion (SVN) server on a Raspberry Pi used to be (relatively) straightforward (see Appendix A).


This worked without problems on an older Raspberry Pi earlier this year when I had the need to set up a test server for some heavy SVN operations (before unleashing them on the real SVN server at work).

However, repeating the same installation steps on a newer Raspberry Pi (model 3, with Wi-Fi) failed to get a working SVN server. Installing an SVN server in another place was a reasonable way to reset the server state such that adding of new files could be tested more than once (and not erasing the rich history on the old server) and also a way of testing the installation procedures should they be needed again in some other place and time.

Having the older server still working I had the luxury of being able to compare configuration files for Apache and SVN. However, nothing appeared to be incorrect.

One difference was that, by the same installation procedure, eight months apart, Apache 2.2 had been installed on the old server and Apache 2.4 on the new server. It later became clear that the way of configuration has changed significantly between Apache 2.2 and Apache 2.4.

Long story short, a symbolic link for enabling the SVN thing in Apache was not created (perhaps a bug in the installation scripts or change to defaults) in the new installation. Detection became:

        ls -ls /etc/apache2/mods-enabled | grep svn

This was empty (symbolic link not present) on the new server, but on the old working server the output was:

        dav_svn.conf -> ../mods-available/dav_svn.conf
        dav_svn.load -> ../mods-available/dav_svn.load
 
There is (apparently) a standard mechanism for making these symbolic links by use of the script a2enmod and the fix/solution was:

        sudo a2enmod dav_svn
        sudo service apache2 restart


Retrospectively, I found a Stack Overflow post, Configuring SVN server on Apache on Ubuntu 12.04,  that had the exact solution. I had failed to locate it (one of the first steps was of course to search on Stack Exchange sites, primarily Stack Overflow, but also Super User and Server Fault).





Appendix A Installing an SVN server on a Raspberry Pi from scratch (with Apache for HTTP access)

These are command lines, done remotely over SSH using PuTTY on Windows.

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

           sudo service apache2 restart

Creating two repositories, "RCL" and "CGW"

           sudo mkdir /var/svn-repos/
           sudo svnadmin create --fs-type fsfs /var/svn-repos/RCL
           sudo svnadmin create --fs-type fsfs /var/svn-repos/CGW

Set permissions

            sudo groupadd subversion
            sudo addgroup pmn subversion
            sudo addgroup pi subversion
            sudo addgroup someOtherSVNuser subversion

            sudo chown -R www-data:subversion /var/svn-repos/*
            sudo chmod -R 770 /var/svn-repos/*

Add to /etc/apache2/mods-available/dav_svn.conf (so HTTP can be used, through Apache (and also enabling browsing from a web browser)):

          sudo vi /etc/apache2/mods-available/dav_svn.conf

            
     <Location /svn>
               DAV svn
               SVNParentPath /var/svn-repos
               AuthType Basic
               AuthName "Subversion Repo"
               AuthUserFile /etc/apache2/dav_svn.passwd
               <LimitExcept GET PROPFIND OPTIONS REPORT>
                   Require valid-user
              
               </LimitExcept>
           </Location>

    

Add an SVN user

           sudo htpasswd -c /etc/apache2/dav_svn.passwd jeremy

             somePassword

Add some content to a repository (locally on the server)

           mkdir /home/pi/projects
           mkdir /home/pi/projects/helloworld
           cd /home/pi/projects/helloworld
           sudo nano main.cpp

           sudo svn import -m 'Some first checked in file' /home/pi/projects/helloworld/ file://localhost/var/svn-repos/CGW


Test in browser (Raspberry Pi server at IP address 192.168.0.120):

   http://192.168.0.120/svn/CGW/