The Ultimate Guide to Setting Up Apache Subversion SVN and TortoiseSVN For Version Control

If your work requires handling documents, web pages, and other type of files that are regularly updated, you may want to use a version control mechanism if you are not doing so already. Among...

Spread the love

If your work requires handling documents, web pages, and other type of files that are regularly updated, you may want to use a version control mechanism if you are not doing so already.

Among other things, this allows you (and a group of potential collaborators as well) to track changes made to a given file, and lets you roll back to a previous version if an issue is encountered or when an update has not produced the expected result.

In the free software ecosystem, the most-widely used version control system is called Apache Subversion (or SVN for short). With the help of mod_dav_svn (Apache’s module for Subversion), you can access a Subversion repository using HTTP and a web server.

That said, let’s roll up our sleeves and install these tools on a RHEL / CentOS 7, Fedora 22-24, Debian 8/7 and Ubuntu 16.04-15.04 server. For our tests we will use a CentOS 7 server with IP

On the client side (a Windows 7 machine), we will install and use TortoiseSVN (which is based on Apache Subversion) as an interface to SVN.

Our Testing Environment

Server - CentOS 7
IP Address -
Client - Windows 7

Step 1 – Installing and Configuring SVN on Linux

As we just mentioned, we will rely on Apache in order to access the SVN repository using a web interface. If it is not installed already, make sure to add it to the list of packages as shown below:

------------------ On CentOS / RHEL / Fedora ------------------ # yum update && yum install mod_dav_svn subversion httpd -y
------------------ On Debian / Ubuntu ------------------ # apt-get update && apt-get install libapache2-svn subversion apache2 -y 

During installation on CentOS 7, an Apache configuration file for SVN will be created as /etc/httpd/conf.modules.d/10-subversion.conf. Open the file and add the following configuration block:


<Location /svn>
DAV svn
SVNParentPath /websrv/svn
AuthType Basic
AuthName "Welcome to SVN"
AuthUserFile /etc/httpd/subversion-auth
Require valid-user
Configure Apache SVN Module

Configure Apache SVN Module

Note: On Debian / Ubuntu you need to add below lines to /etc/apache2/mods-enabled/dav_svn.conf file.


<Location /svn>
DAV svn
SVNParentPath /websrv/svn
AuthType Basic
AuthName "Welcome to SVN"
AuthUserFile /etc/apache2/subversion-auth
Require valid-user

On Debian / Ubuntu, you need to enable dav_svn Apache module:

# a2enmod dav_svn

A couple of clarifications:

  1. The SVNParentPath directive indicates the directory where our repositories will be later created. If this directory does not exist (which is most likely the case), create it with:
    # mkdir -p /websrv/svn

    It is important to note that this directory must NOT be located inside, or overlap, the DocumentRoot of a virtual host currently being served by Apache. This is a showstopper!

  2. The AuthUserFile directive indicates the file where the credentials of a valid user will be stored. If you want to allow everyone to access SVN without authentication, remove the last four lines in the Location block. If that is the case, skip Step 2 and head directly to Step 3.
  3. Although you may be tempted to restart Apache in order to apply these recent changes, don’t do it yet as we still need to create the authentication file with valid users for SVN, and the repository itself.

Step 2 – Add Allowed Users to Access SVN

We will now use htpasswd to create a password for accounts that will be allowed to access SVN. For the first user only, we will need the -c option.

Allowed accounts and bcrypt-encrypted passwords (-B) will be stored in /etc/httpd/subversion-auth in key-value pairs. Note that by today’s standards, the default MD5 or SHA encryption used by htpasswd are considered insecure.

------------------ On CentOS / RHEL / Fedora ------------------ # htpasswd -cB /etc/httpd/subversion-auth tecmint
------------------ On Debian / Ubuntu ------------------ # htpasswd -cB /etc/apache2/subversion-auth tecmint

Don’t forget to set the right ownership and permissions to the authentication file:

------------------ On CentOS / RHEL / Fedora ------------------ # chgrp apache /etc/httpd/subversion-auth
# chmod 660 /etc/httpd/subversion-auth
------------------ On Debian / Ubuntu ------------------ # chgrp www-data /etc/apache2/subversion-auth
# chmod 660 /etc/apache2/subversion-auth

Step 3 – Add Security and Create SVN Repository

Since you will be accessing SVN via a web interface, you will need to allow HTTP (and optionally HTTPS) traffic through your firewall.

------------------ On CentOS / RHEL / Fedora ------------------ # firewall-cmd --add-service=http --permanent
# firewall-cmd --add-service=https --permanent
# firewall-cmd --reload 

By reloading the firewall configuration with --reload, the permanent settings are put into effect immediately.

Create an initial SVN repository called tecmint:

# svnadmin create /websrv/svn/tecmint

Change the owner and group owner to apache recursively:

------------------ On CentOS / RHEL / Fedora ------------------ # chown -R apache:apache /websrv/svn/tecmint
------------------ On Debian / Ubuntu ------------------ # chown -R www-data:www-data /websrv/svn/tecmint

Finally, you will need to change the security context of /websrv/svn/tecmint (note that you will have to repeat this step if you decide to create other repositories later):

------------------ On CentOS / RHEL / Fedora ------------------ # chcon -R -t httpd_sys_content_t /websrv/svn/tecmint/
# chcon -R -t httpd_sys_rw_content_t /websrv/svn/tecmint/

Note: The last two commands may not apply if you’re installing SVN on a VPS with SELinux disabled.

Suggested Read: Learn How to Disable SELinux Temporarily or Permanently in Linux

Restart Apache and verify the repository is available.

------------------ On CentOS / RHEL / Fedora ------------------ # systemctl restart httpd
------------------ On Debian / Ubuntu ------------------ # systemctl restart apache2

Then launch a web browser and point it to After entering the credentials for the valid user that we created in Step 1, the output should be similar to:

Access SVN Repository via Browser

Access SVN Repository via Browser

At this point we have not added any code to our repository. But we will do that in a minute.

Step 4 – Install TortoiseSVN in the Windows 7 Client

As we mentioned in the introduction, TortoiseSVN is an user-friendly interface to Apache Subversion. It is Free Software licensed under the GPL and can be downloaded from

Choose the architecture (32 or 64-bit) that corresponds to your machine and install the program before proceeding.

Step 5 – Setup SVN Repository on Client Machine

In this step we will use a folder named webapp inside Documents. This folder contains a HTML file, and two folders named scripts and styles with a Javascript and a CSS file (script.js and styles.css, respectively) that we want to add to version control.

Right click webapp and choose SVN Checkout. This will create a local copy of the remote repository (which is empty at the moment) and initialize the folder for version control:

Configure SVN on Client Directory

Configure SVN on Client Directory

In URL of repository, type and make sure the local checkout directory remains the same, then click OK:

Configure SVN Repository on Client

Configure SVN Repository on Client

Enter the username and password (refer to Step 2) and click OK:

Enter Credentials of SVN User

Enter Credentials of SVN User

You will be asked whether you want to checkout into a non-empty directory. Confirm to proceed with the checkout. Once it is complete, a green checkmark will appear next to the folder name:

Check Out SVN Directory

Check Out SVN Directory

Step 6 – Commit Changes and Deploy Files to Remote SVN Repository

Right click on webapp again and choose Commit this time. Next, write a descriptive comment to later identify this commit, and check the files and folders you want to deploy to the repository. Finally, click OK:

Deploy Files to Remote SVN Repository

Deploy Files to Remote SVN Repository

Depending on the size of files, the commit should not take more than a minute. When it is complete, you will see that we are now on revision 1, which matches the version and files listed in the web interface:

Confirm SVN Repository Revision

Confirm SVN Repository Revision

If there are several people working on the same files, you’ll want to Update your local copy in order to have the latest version available to work on. You can do that by right clicking on webapp and choosing Update from the context menu.

Congratulations! You have successfully setup a SVN server and commited / updated a simple project under version control.


In this article we have explained how to install and configure an Apache Subversion repository server on a CentOS 7 server, and how to commit changes to that repository using TortoiseSVN.

Please note there is much more to SVN and TortoiseSVN than what we can adequately cover here (specially how to return to previous revisions), so you may want to refer to the official docs (SVN and TortoiseSVN) for more information and configuration cases.

As always, don’t hesitate to let us know if you have any questions! Feel free to use the comment form below to reach us anytime.

Facebook Comments
Spread the love

Posted by News Monkey