Installing and setting up Subversion on a WHM/Cpanel machine

This post is desired to be a 101 on installing and setting up Subversion on a WHM/Cpanel machine.

1. The following was tested using WHM version 11.30.4 (build 6), installed in CentOS 5.7
2. The following reference will be used:
example = referring to the account name of a cPanel account set up in WHM = the domain for which the example account was set up for
3. You will need to get dirty with the terminal using SSH access
4. The setup is going to use Apache’s mod_dav for authentication

Installing mod_dav (if needed)

First, check to see if mod_dav isn’t already installed on your system by running the following command in the terminal:

root@machine [~]# /sbin/service httpd -M | grep dav

If mod_dav is already installed, it will return:

dav_module (static)
dav_fs_module (static)

If not, you will have to rerun EasyApache (EasyApache is a script used by WHM installations to configure Apache). You can do this by clicking on the EasyApache (Apache Update) link in the WHM menu. Select the most suitable profile to load based on what you are using the server for (if this is not a fresh server, it is better to read the EasyApache documentation before proceeding so that you don’t lose prior configurations). When you reach step 6 (Exhaustive Options List) be sure to check DavFS and Dav in the Apache Built-in Modules list. Save and build.
Note: Running EasyApache will shut down your webserver for about five minutes.

Install Subversion

In order to properly configure it, Subversion needs to be compiled from its sources. First, go to and copy the link pointing to the .tar.gz archive (in my case, Now, download the source and unpack it:

root@machine [~]# cd /usr/local/src/
root@machine [/usr/local/src]# wget
root@machine [/usr/local/src]# tar -xvf subversion-1.6.17.tar.gz

Before compiling Subversion, SQLite needs to be copied to the sources. Go to and get the link for the latest tarball. In my case, this is

root@machine [/usr/local/src]# wget
root@machine [/usr/local/src]# tar -xvf sqlite-autoconf-3070800.tar.gz
root@machine [/usr/local/src]# cd subversion-1.6.17
root@machine [/usr/local/src/subversion-1.6.17]# mkdir sqlite-amalgamation
root@machine [/usr/local/src/subversion-1.6.17]# cp ../sqlite-autoconf-3070800/sqlite3.c ./sqlite-amalgamation/

Now, you need to configure Subversion in order to install it:

root@machine [/usr/local/src/subversion-1.6.17]# ./configure --with-apxs=/usr/local/apache/bin/apxs --with-apr=/home/cpeasyapache/src/httpd-2.2.19/srclib/apr --with-apr-util=/home/cpeasyapache/src/httpd-2.2.19/srclib/apr-util
root@machine [/usr/local/src/subversion-1.6.17]# make && make install

You may need to update your path to httpd, if you get the following error:

checking for APR... configure: error: the --with-apr parameter is incorrect. It must specify an install prefix, a build directory, or an apr-config file.
root@machine [/usr/local/src/subversion-1.6.17]# cd /home/cpeasyapache/src/
root@machine [/home/cpeasyapache/src]# ls -all

Look for httpd-*.*.** (where the stars are your script version) and update accordingly. cd back to the subversion directory and run the configure, make and make install commands again.

Subversion and Apache

Given you are using WHM and it uses EasyApache, you can’t just modify the Apache configuration to include the Subversion modules. Instead, you must use the Include Editor, which you can find by browsing to “Apache Configuration” in the WHM menu. There, you must use the Pre Main Include. Select the latest Apache version from the dropdown list and a textarea will appear. Add the following to it and click on “Update”:

LoadModule dav_svn_module modules/
LoadModule authz_svn_module modules/

Add Subversion users

Run the following command for every user you wish to add. You will be asked for passwords for each one:

root@machine [~]# /usr/local/apache/bin/htpasswd -cm /etc/svn-auth-conf username

Set up your first repository

I am assuming you are going to set up more than one repository on one domain, but this also applies to when you want just one repository.

First, you need to add a new virtual host for your repository:

root@machine [~]# cd /etc/httpd/conf/userdata/std/2/

If you get a “-bash: cd: /etc/httpd/conf/userdata/std/2/: No such file or directory” error, run these commands to create the folder:

root@machine [~]# mkdir /etc/httpd/conf/userdata
root@machine [~]# mkdir /etc/httpd/conf/userdata/std
root@machine [~]# mkdir /etc/httpd/conf/userdata/std/2

Now, add a folder for your domain:

root@machine [~]# mkdir /etc/httpd/conf/userdata/std/2/example
root@machine [~]# mkdir /etc/httpd/conf/userdata/std/2/example/
root@machine [~]# cd /etc/httpd/conf/userdata/std/2/example/

Next, you need to create the Subversion config file

root@machine [/etc/httpd/conf/userdata/std/2/example/]# nano svn_custom.conf

Paste the following config and save the file. For every repository you wish to create, add another <location> block

<IfModule mod_dav_svn.c>
    #begin location
    <location /repo>
	DAV svn
	SVNPath /home/example/public_svn/repo/svn/
	AuthType Basic
	AuthName "SVN Repo"
	AuthUserFile /home/example/.svn.htpasswd
	Require valid-user
    #end location

Notice that we are using a folder called public_svn, outside the standard public_html folder. It is not recommended to add repositories in the same place as the public webserver files, because you are going to confuse Apache when you are going to try to access the repository through a local Subversion interface. Although you will be able to load the repository in your browser, you will get a “Repository moved permanently to ‘’; please relocate” error when trying to access remotely. This happens because Apache doesn’t know how to respond to the request and gets confused on what it should return.

Now, create the actual repository files:

root@machine [~]# su example
example@machine [/root]# cd ~
example@machine [~]# mkdir public_svn
example@machine [~]# mkdir public_svn/repo
example@machine [~]# cd public_svn/repo
example@machine [~/public_svn/repo]# svnadmin create svn
example@machine [~/public_svn/repo]# chmod 775 -R svn
example@machine [~/public_svn/repo]# exit

Update the Apache configuration and you are all set up:

/scripts/ensure_vhost_includes --all-users

Go to to test your repository. It should ask for your user and password and then show you something like the following: