Last Update 4/6/2018 – Refer to this cpanel article for EA4 help https://forums.cpanel.net/threads/svn-install-on-centos-7-ea4.613563/.
UPDATED 2/11/2016. I use this document as a reference for myself and my company, every time I have issues with SVN (easyapache updates can cause the SVN installation to break) I just refer to this article, and follow the steps, It always seems to fix the issues.
I have read many posts on installing Subversion on WHM servers. A few were helpful, one was pretty good, but none of them worked for a long time. EasyApache updates would break most the installations. This is my method of installing (and updating) Subversion on a WHM server so that it will not be broken by EasyApache rebuilds.
This process has been used on a number of servers in 2013 and 2014. All were CentOS and WHM. I do not think the exact versions of each matter, and the process would be similar for related versions of Linux.
In this Post, The term svnaccount** is used to identify the user account name that will be used to host the Subversion url.
The term svndomain** is used to indicate the domain name that will be used to access the Subversion repository.
- Install mod_dav
- Install Subversion
- Subversion and Apache
- Setup Subversion Repository
- Add Subversion Users
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 run 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 for Exhaustive Options List be sure to Dav in the Apache Built-in Modules list. Some article indicate that DAVFs is needed as well. I have it both ways and it does not seem to matter if DAVFs is selected or not. Save and build. Note: Running EasyApache will take a few minutes. Your httpd service will be restarted at the end of the process to activate the new build.
In order to properly configure latest version of Subversion it needs to be compiled from its sources.
First, go to http://subversion.apache.org/download/#recommended-release and copy the link pointing to the .tar.gz archive (at the time of this post that latest version tarball is at ,http://apache.mirrors.hoobly.com/subversion/subversion-1.8.13.tar.gz). Login to SSH as root user , download the source and unpack it:
root@machine [~]# cd /usr/local/src/ root@machine [/usr/local/src]# wget http://apache.mirrors.hoobly.com/subversion/subversion-1.8.13.tar.gz root@machine [/usr/local/src]# tar -xvf subversion-1.8.13.tar.gz
Before compiling Subversion, SQLite needs to be copied to the sources. Go to http://www.sqlite.org/download.html and get the link for the latest tarball. (at the time of this post the latest tarball is at http://sqlite.org/2015/sqlite-autoconf-3080900.tar.gz
root@machine [/usr/local/src]# wget http://sqlite.org/2015/sqlite-autoconf-3080900.tar.gz root@machine [/usr/local/src]# tar -xvf sqlite-autoconf-3080900.tar.gz root@machine [/usr/local/src]# cd subversion-1.8.13 root@machine [/usr/local/src/subversion-1.8.13]# mkdir sqlite-amalgamation root@machine [/usr/local/src/subversion-1.8.13]# cp -r ../sqlite-autoconf-3080900/* ./sqlite-amalgamation/
Now, you need to configure Subversion in order to install it:
root@machine [/usr/local/src/subversion-1.8.13]# ./configure --with-apxs=/usr/local/apache/bin/apxs --with-apr=/home/cpeasyapache/src/httpd-2.2/srclib/apr --with-apr-util=/home/cpeasyapache/src/httpd-2.2/srclib/apr-util root@machine [/usr/local/src/subversion-1.8.13]# 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.8.13]# ls -all /home/cpeasyapache/src/
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.
EA4 – The location of apxs has moved. the latest configure command I have used is ..
./configure --with-apxs=/usr/bin/apxs --with-apr=/home/cpeasyapache/src/httpd-2.4/srclib/apr --with-apr-util=/home/cpeasyapache/src/httpd-2.4/srclib/apr-util
Subversion and Apache
When using WHM and 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”: (Note — The make install command used whenn installing Subversion in the above step, will put the .so files in these folders. IF you copy them to the standard apache modules folder, then when you rebuild apache using easyApache, and you will trust me, then the files will be deleted and your easyapache rebuild will break due to these include files not being in the modules folder. )
LoadModule dav_svn_module /usr/local/libexec/mod_dav_svn.so LoadModule authz_svn_module /usr/local/libexec/mod_authz_svn.so
Set up your first repository
I use one repository per domain / subdomain. These instruction will work for multiple repositories.
First, you need to add a new virtual host for your repository: (NOTE: apache 2.4 users check if your server uses /2_4/ folder instead of /2/ )
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/svnaccount** root@machine [~]# mkdir /etc/httpd/conf/userdata/std/2/svnaccount**/svndomain** root@machine [~]# cd /etc/httpd/conf/userdata/std/2/svnaccount**/svndomain**
Next, you need to create the Subversion config file
root@machine [/etc/httpd/conf/userdata/std/2/svnaccount**/svndomain**]# 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/svnaccount**/public_svn/repo/svn/ AuthType Basic AuthName "SVN Repo" AuthUserFile /home/svnaccount**/.svn.htpasswd Require valid-user </location> #end location </IfModule>
We use a folder called public_svn which is 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 ‘http://example.com/repo/’; 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 svnaccount** example@machine [/root]# cd ~ svnaccount**@machine [~]# mkdir public_svn svnaccount**@machine [~]# mkdir public_svn/repo svnaccount**@machine [~]# cd public_svn/repo svnaccount**@machine [~/public_svn/repo]# svnadmin create svn svnaccount**@machine [~/public_svn/repo]# chmod 775 -R svn
Stay logged in at the svnaccount** user.
Add Subversion users
Run the following command to create the new password file with its first user. You will be asked for password:
svnaccount**@machine [~]# /usr/local/apache/bin/htpasswd -cm ./.svn.htpasswd username
For each additional user, run the following command: (remove the -c option)
svnaccount**@machine [~]# /usr/local/apache/bin/htpasswd -m ./.svn.htpasswd username
When you have added all the users you need (you can always add more later) Logout of the svnaccount**. You should be back to root access.
svnaccount**@machine [~]# exit
For most VPS hosting accounts that use CentOS you will need to change the permissions on the repo folder so that the svn module can write to the the filesystem. The httpd service runs as nobody so we set the nobody group on the repo folder. If you dont do this you will be able to browse the repository, but not modify it.
root@machine [~]# chown -R svnaccount**:nobody /home/svnaccount**/public_svn/repo
Tell cPanel to update the Apache configuration to use the custom vhost includes:
Go to http://svndomain**/repo to test your repository. It should ask for your user and password and then show you something like the following: