How to Install Apache SVN (Subversion) on CentOS 7/RHEL

Hi everyone, today in this tutorial we'll be installing Apache SVN also popular as Subversion on our CentOS 7 or RHEL 7 which is an awesome tool for version control system which is suitable from small project to large projects.  So, here is some information on what really is Apache SVN (Subversion).

Apache Subversion (often abbreviated SVN, after the command name svn) is a software versioning and revision control system distributed as free software under the Apache License. Developers use Subversion to maintain current and historical versions of files such as source code, web pages, and documentation. Its goal is to be a mostly compatible successor to the widely used Concurrent Versions System (CVS).

The free software community has used Subversion widely: for example in projects such as Apache Software Foundation, Free Pascal, FreeBSD, GCC, Mono and SourceForge. Google Code also provides Subversion hosting for their free software projects. CodePlex offers access to Subversion as well as to other types of clients.

The corporate world has also started to adopt Subversion. A 2007 report by Forrester Research recognized Subversion as the sole leader in the Standalone Software Configuration Management (SCM) category and as a strong performer in the Software Configuration and Change Management (SCCM) category.

So, let's install SVN in our CentOS or RHEL 7 machine. We'll need to install a Web Server first to make our Subversion working. Here are the steps below which will let us fully set up it out of the box.

1. Installing a Web Server

So, before we install a Web server, we'll need to update the yum package repository:

# yum update

Now, we will install Apache server as web server for the SVN repository.

# yum -y install httpd httpd-tools
install httpd

Now, we'll need to allow http through our firewall. You can do that with the command below.

# firewall-cmd --permanent --zone=public --add-service=http
# firewall-cmd --reload
firewalld cmd

If you get error like we have got above, then you must be sure that Firewalld is not installed or not running. So, you'll need to install firewalld using "yum install firewalld" and start the service with "systemctl start firewalld" without quotes("") as shown above.

Now, we'll wanna start our Apache and verify if its running fine by visiting http://localhost or http://ip-address .

# systemctl start httpd.service

2. Installing Subversion

Once the Apache Web Server is installed, we'll need to execute the following command to install subversion.

# yum -y install subversion subversion-tools mod_dav_svn

install subversion

3. Configuring Subversion

After we've done installing subversion, we can now start to create repositories as per the requirements. In our case we'll be creating /svn as the base and will create the repository in it.

Note: You can select the directory where you wanna create your Repository and replace /svn with it.

# mkdir /svn

Now, we'll create a repository called “linoxiderepo” under "/svn/" directory as

# svnadmin create /svn/linoxiderepo

Change the permission of the repository in such a way that Apache can read and write it.

# chown -R apache:apache /svn/linoxiderepo/
configuring subversion

If you have SELinux enabled on the system, run the following command.

# chcon -R -t httpd_sys_content_t /svn/linoxiderepo/
# chcon -R -t httpd_sys_rw_content_t /svn/linoxiderepo/

4. Configuring Apache Server

Configure virtual host in Apache.

# nano /etc/httpd/conf.d/svn.conf

Place the following content.

<location /svn>
DAV svn
SVNParentPath /svn
configuring apache server

Then, we'll need to restart the apache server to take effect.

# systemctl reload httpd.service
reload httpd

Now, we should be able to access the SVN using your favorite browser, we'll need to go to http://our-ip-address/svn/linoxiderepo . It wont ask us any password to view so, it makes our SVN repository publicly accessible. If we want to secure our SVN repository then, we'll need to follow the steps below.

5. Securing SVN: (Optional)

The above setting would allow anonymous users to view and commit the files. To stop the anonymous access, you have to edit the apache configuration which was created just two steps before.

# nano /etc/httpd/conf.d/svn.conf

We'll gonna add the following contents in that file.

<location /svn>
DAV svn
SVNParentPath /svn/
AuthType Basic
AuthName "Authorization Realm"
AuthUserFile /etc/subversion/svn.users
Require valid-user
secure svn.conf

Created the password file for the user.

# htpasswd -cm /etc/subversion/svn.users arun

Now, Restart the apache server.

# systemctl reload httpd.service
secure svn repo

6. Testing Subversion

Finally we can visit the url http://our-ip-address/svn/linoxiderepo in our browser to check out the content, you will be asked to enter the user name and password (If you have setup the Secure SVN).

Upon successful login, contents will be listed like below.

Create a template directory and import into SVN.

# mkdir -p /tmp/repository/project/{trunk,branches,tags}
# svn import -m 'Initial Import' /tmp/repository/project/
svn import shell

In the Browser after the import.

svn import


Hurray! We have successfully installed Apache SVN (Subversion) along with Apache Web Server to host the repository in our CentOS 7. This tutorial is also applicable for RHEL 7 ( Hat Enterprises Linux) . Apache SVN  is an awesome tool for version control system which is suitable from small development project to huge projects. We'll need a SVN client such as Tortoisesvn for windows and Rapidsvn for Linux which are some good GUI front-end for the Subversion revision system. So, if you have any questions, comments, feedback please do write on the comment box below and let us know what stuffs needs to be added or improved. Thank You! Enjoy Apache SVN (Subversion).

9 Comments... add one

  1. Hi there, to install svn v1.8 on RHEL7, all the steps above is the same, you just need to add a repository for svn 1.8 in step 2 (just before installing subversion).
    You'll need to create a new file /etc/yum.repos.d/wandisco-svn.repo and add the following lines in it.

    name=Wandisco SVN Repo

    After adding the above lines to the repo file. Enter the following command in a shell or terminal :
    # yum clean all
    then, install subversion from above step 2.

      • Hi Tyler thanks for your comment. The installation for svn_mod_dav is mentioned in the step no. 2 which you can install with yum install svn_mod_dav too. Thanks :)

        • I think the question is if subversion-libs 1.7.14-7 from the Centos 7 repo will work with the Subversion 1.8 binaries. After all they are supposed to match.

  2. Thanks for the guide. You cannot imagine how many rubbish guides i went through to install it properly. People like to complicate things for no reason. However this is a precise step by step installation.

    What would be also useful to add is a way to show how to edit the folder level access file in SVN to provide access to specific users.

    Thank you.


Leave a Comment