How to install Subversion on cPanel 11.50.x and higher
** Minimum HTTPD 2.4.16 required. HTTPD 2.4.12 will NOT work due to a security hole **
This tutorial will walk you through the steps to installing Subversion 1.8.14 on cPanel. You will end up with a command line version and the ability to access your SVN repositories via the browser securely.
If SVN is already installed on your server, be sure to remove it with 'yum remove svn'
Let's get started!
Install dependencies
yum install apr-devel zlib expat-devel
rpm -Uvh http://prdownloads.sourceforge.net/scons/scons-2.3.6-1.noarch.rpm
Download Subversion source
cd /usr/local/src
wget http://apache.mirror.gtcomm.net/subversion/subversion-1.8.14.tar.gz
sha1sum subversion-1.8.14.tar.gz
tar -zxvf subversion-1.8.14.tar.gz
cd subversion-1.8.14
Install sqlite-amalgamation
wget http://www.sqlite.org/2015/sqlite-amalgamation-3081101.zip
unzip sqlite-amalgamation-3081101.zip
mv sqlite-amalgamation-3081101 sqlite-amalgamation
Install Serf
cd /usr/local/src
wget http://serf.googlecode.com/svn/src_releases/serf-1.3.8.tar.bz2
tar -xjf serf-1.3.8.tar.bz2
cd serf-1.3.8
scons APR=/usr/local/apache/bin/apr-1-config APU=/usr/local/apache/bin/apu-1-config PREFIX=/usr/local/serf
# If you run `scons check` you will get a fair number of errors. Ignore these.
scons install
Build and install Subversion
cd ../subversion-1.8.14
./configure --with-apxs=/usr/local/apache/bin/apxs --with-apr=/usr/local/apache/bin/apr-1-config --with-apr-util=/home/cpeasyapache/src/httpd-2.4/srclib/apr-util --with-openssl CC="gcc -std=gnu99" --with-serf=/usr/local/serf
make
make install
Link libraries
ln -s /usr/local/serf/lib/libserf-1.so.1 /usr/local/lib/libserf-1.so.1
ln -s /usr/local/serf/lib/libserf-1.so.1.3.0 /usr/local/lib/libserf-1.so.1.3.0
Verify we have a good version
svn --version
svn, version 1.8.14 (r1692801)
compiled Aug 27 2015, 14:19:24 on x86_64-unknown-linux-gnu
Copyright (C) 2015 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.8
- handles 'http' scheme
- handles 'https' scheme
Add modules to Apache in cPanel
If you plan on accessing your SVN repositories in the browser, you can do this with mod_dav_svn and mod_authz_svn. You simply need to include these two modules in cpanel.
- Login to cpanel
- Navigate to Service Configuration --> Apache Configuration --> Include Editor
- Under Pre Main Include, select All Versions from the drop down.
- Add the following two lines
LoadModule dav_svn_module /usr/local/libexec/mod_dav_svn.so LoadModule authz_svn_module /usr/local/libexec/mod_authz_svn.so
- Click on Update
- Click Restart Apache
You're done!
If everything went as it should have gone, you will now have Subversion installed on your cpanel box.
Configuring cPanel for web access to SVN
This is a quick how-to addendum as someone was asking how to do this. There are a few files you need to make SVN accessible from the browser. First up, you will need to add an apache configuration file for your domain. For the purpose of this how-to, our repositories are accessible from example.com/svn. You can find more information on cPanel Apache config files here.
cd /usr/local/apache/conf/userdata/ssl/2/
# This path is for https, if you use http, change the path below from ssl to std.
mkdir -p ./user/example.com/
vim example.com.conf
# Past this into the file, being sure to first replace 'user' with your domains username and example.com with your domain
<ifmodule mod_dav_svn.c="">
<location svn="">
DAV svn
SVNParentPath /home/user/svnrepos
# our access control policy
AuthzSVNAccessFile /home/user/svnauth/svn-access-file
# only authenticated users may access the repository
Satisfy Any
Require valid-user
# how to authenticate a user - change path to suit your needs
AuthType Basic
AuthName "SVN members only"
AuthUserFile /home/user/svn_auth/svn-auth-file
# location os xsl file. Change to suit your needs.
SVNIndexXSLT "/css/svn/svnindex.xsl"
ModMimeUsePathInfo on
</location>
</ifmodule>
<directory home="" user="" public_html="">
AllowOverride None
</directory>
You'll need to tell cpanel that you've added this file and then restart apache for the changes to take affect. Be sure to run a configtest (service httpd configtest) before restarting, in case you have a typo.
Next, you will need to be sure that you have the correct assets in place in the domain.
cd /home/example.com/public_html
mkdir -p css/svn
vim svnindex.xsl
# paste the following into the svnindex.xsl file:
<!--?xml version="1.0"?-->
<!-- A sample XML transformation style sheet for displaying the Subversion
directory listing that is generated by mod_dav_svn when the "SVNIndexXSLT"
directive is used. -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html"></xsl:output>
<xsl:template match="*"></xsl:template>
<xsl:template match="svn">
<title>
<xsl:if test="string-length(index/@name) != 0">
<xsl:value-of select="index/@name"></xsl:value-of>
<xsl:text>: </xsl:text>
</xsl:if>
<xsl:value-of select="index/@path"></xsl:value-of>
</title>
<link rel="stylesheet" type="text/css" href="/svnindex.css">
<div class="svn">
<xsl:apply-templates></xsl:apply-templates>
</div>
<div class="footer">
<xsl:text>Powered by </xsl:text>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="@href"></xsl:value-of>
</xsl:attribute>
<xsl:text>Subversion</xsl:text>
</xsl:element>
<xsl:text> </xsl:text>
<xsl:value-of select="@version"></xsl:value-of>
</div>
</xsl:template>
<xsl:template match="index">
<div class="rev">
<xsl:if test="string-length(@name) != 0">
<xsl:value-of select="@name"></xsl:value-of>
<xsl:if test="string-length(@rev) != 0">
<xsl:text> — </xsl:text>
</xsl:if>
</xsl:if>
<xsl:if test="string-length(@rev) != 0">
<xsl:text>Revision </xsl:text>
<xsl:value-of select="@rev"></xsl:value-of>
</xsl:if>
</div>
<div class="path">
<xsl:value-of select="@path"></xsl:value-of>
</div>
<xsl:apply-templates select="updir"></xsl:apply-templates>
<xsl:apply-templates select="dir"></xsl:apply-templates>
<xsl:apply-templates select="file"></xsl:apply-templates>
</xsl:template>
<xsl:template match="updir">
<div class="updir">
<xsl:text>[</xsl:text>
<xsl:element name="a">
<xsl:attribute name="href">..</xsl:attribute>
<xsl:text>Parent Directory</xsl:text>
</xsl:element>
<xsl:text>]</xsl:text>
</div>
<!-- xsl:apply-templates/ -->
</xsl:template>
<xsl:template match="dir">
<div class="dir">
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="@href"></xsl:value-of>
</xsl:attribute>
<xsl:value-of select="@name"></xsl:value-of>
<xsl:text>/</xsl:text>
</xsl:element>
</div>
<!-- <xsl:apply-templates/ -->
</xsl:template>
<xsl:template match="file">
<div class="file">
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="@href"></xsl:value-of>
</xsl:attribute>
<xsl:value-of select="@name"></xsl:value-of>
</xsl:element>
</div>
<!-- xsl:apply-templates/ -->
</xsl:template>
</xsl:stylesheet>
Finally, you will need to create a CSS file to place in your site root (you can change the path if you wish for any of these files in the apache conf and the svnindex.xsl file
cd /home/example.com/public_html
touch svnindex.css
If you now browse to http://example.com/svn/reposname you should see you content. It won't be pretty as you haven't added a style sheet yet. You can find a reasonable starting point for styles from this repository on Source Forge
Let me know if this works or not, I'm happy to update the tutorial if there are bugs.