How to configure Subversion + Apache [mod_dav_svn.so] in CPanel

It is very easy to setup a subversion repository and access it via browser as I found out recently from my own experience.

The below case was on a Cpanel server, but you can follow the same method (with some tweaks, of course) on any subversion + apache environment as long as you have the apache source code with you. Here, I am installing subversion for Cpanel user “example” which hosts “example.com”.

The exact procedure to install mod_dav_svn is given below:

1. Install subversion via yum (you can install from source if required. You will need its source in anycase)

root@server [~]# yum -y install subversion
root@server [~]# svn --version
svn, version 1.5.0 (r31699)
compiled Aug 27 2010, 15:18:12

Copyright (C) 2000-2008 CollabNet.
Subversion is open source software, see http://subversion.tigris.org/
This product includes software developed by CollabNet (http://www.Collab.Net/).

The following repository access (RA) modules are available:

* ra_svn : Module for accessing a repository using the svn network protocol.
- handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
- handles 'file' scheme

2. Download the subversion source, and extract the tarball

[root@server ~]# cd /usr/local/src
[root@server src]# wget http://subversion.tigris.org/downloads/subversion-1.5.0.tar.bz2
[root@server src]# tar xfvj subversion-1.5.0.tar.bz2
[root@server src]# cd subversion-1.5.0

3. Install the tarball. Make sure you change the paths for apr and apr-util as required:

[root@server subversion-1.5.0]# ./configure
--with-apxs=/usr/local/apache/bin/apxs
--with-apr=/home/cpeasyapache/src/httpd-2.0.63/srclib/apr
--with-apr-util=/home/cpeasyapache/src/httpd-2.0.63/srclib/apr-util
[root@server subversion-1.5.0]# make
[root@server subversion-1.5.0]# make install

4. You should now see the new apache modules installed:

root@server [~]# ls -l /usr/local/apache/modules/ | grep svn
-rwxr-xr-x  1 root root    29870 Aug 28 14:42 mod_authz_svn.so
-rwxr-xr-x  1 root root   538955 Aug 28 14:42 mod_dav_svn.so

5. Time to create the subversion repository “test”:

[root@server ~]# mkdir /home/example/subversion
[root@server ~]# svn mkdir file:////home/example/subversion/test/trunk -m "Truck"
[root@server ~]# svn mkdir file:////home/example/subversion/test/tags -m "Tags"
[root@server ~]# svn mkdir file:////home/example/subversion/test/branches -m "Branches"
[root@server ~]# chown example.example /home/example/subversion -vR

6. Ccreate a separate include file for example.com to add the SVN entries:

[root@server ~]# cat
/usr/local/apache/conf/userdata/std/2/example/example.com/svn.conf
<Location /subversion>
DAV svn
SVNParentPath /home/example/subversion
</Location>

7. Make sure you include the created file in VirtualHost of example.com, and then restart apache now

[root@server ~]# service httpd restart

8. If everything works well, you should be able to access repository via http://example.com/subversion/test/

Leave a Reply