How to Set up SVN with Apache

How to Set up SVN with Apache

17 Comments on How to Set up SVN with Apache

This is a tutorial on how to set up SVN with Apache, create users accounts and also disable anonymous viewing of the project from a web browser. Subversion also known as SVN is a tool that remembers versions of a project and takes notes of changes. If someone was to write code or even a novel and commit changes to SVN and a mistake was made, they could easily go back to a previous revision.

To install Subversion and the Apache module run the following command:

sudo apt-get install subversion libapache2-svn

Setting up SVN
The first that needs to be done is to set up a group for subversion:

sudo addgroup subversion

The next thing is to make a directory for the SVN repository. I usually create it in the root directory named repo or svn:

sudo mkdir /repo

The premissions and owner of the repo directory have to be changed. The owner of the directory to www-data and the group needs to be subversion:

sudo chown www-data:subversion /repo
sudo chmod g+rws /repo

To create the actual SVN repository svnadmin is used with create. You can use any name you like for the SVN repository:

sudo svnadmin create /repo/YourRepoName

The owner and permissions have to be changed on the repository:

sudo chown www-data:subversion /repo/YourRepoName
sudo chmod g+rws /repo/YourRepoName

Setting up the Apache Module
Edit the file /etc/apache2/mods-available/dav_svn.config with your favourite editor. I like to use nano:

sudo nano /etc/apache2/mods-available/dav_svn.config

At the bottom of the file add the following lines:

<Location /svn/yourrepo>
    DAV svn
    SVNPath /repo/mpshouse
    AUTHType Basic
    AUTHName "Your Subversion Repository"
    AuthUserFile /etc/subversion/passwd
    Require valid-user

The 2 lines that need attention are the first, the sixth ans the last. The first line:

<Location /svn/yourrepo>

has /svn/yourrepo in it which will be the address that you can access your SVN. If your domain is, you can access the SVN at The sixth line:

AuthUserFile /etc/subversion/passwd

is where the password file is located. The last line:

Require valid-user

will stop anonymous browsing of your projects and force the browser to show an authentication dialog to continue.

Adding a User Account
To add a user account to a new password file the -c flag is used. If the file already exists and a new user needs to be added to an existing file the -c flag is not needed. The password file needs to be created in the directory specified in the dav_svn.config file that was just edited. The command will ask you for the password of the user after pressing enter.

sudo htpasswd -c /etc/subversion/passwd bill

About the author:

Bill Payne started working as a paid professional software developer at the young age of 12 years old developing simple games and other applications for pre-packaged computers. Bill has since developed software for many industries such as direct sales and the the stock market. Bill has now started sharing his many years of software development experience through a blog on the MPSHouse website and one on one lessons.


  1. Tom  - 16 April , 2012 - 12:33 am
    Reply /

    Great! Simple, straightforward.

    Would you please take it to the next level and show the configs to make this SVN server use https?


  2. windows xp password recovery  - 29 April , 2012 - 1:51 pm
    Reply /

    windows xp password recovery…

    […]How to Set up SVN with Apache – A blog about Linux, Windows, OSX, servers and programming.[…]…

  3. rushdy  - 7 October , 2012 - 11:41 am
    Reply /

    dear sir,
    kindlyi need to know is it work for making svn update in backtrack5 r3 ?and should i use it from command line or terminal ????????????
    best regards

    • bill  - 9 October , 2012 - 1:36 pm
      Reply /

      I am not sure what you mean… The command line and terminal is the same thing.

  4. optyler  - 12 January , 2013 - 12:03 am
    Reply /


    first of all, thank you for that small and usefull installation guide!

    I have a question about dumps, i just finish my dump :
    svnadmin dump /path/to/reponame > /tmp/repo1.dump

    and i’am about to inject it in my new server with :
    svnadmin load /path/to/reponame < /tmp/repo1.dump

    My question is : do I need to set again the rights for the repository sub-directories?

    something like :
    sudo chown www-data:subversion /repo/YourRepoName/subdirxxx
    sudo chmod g+rws /repo/YourRepoName/subdirxxx


    • bill  - 12 January , 2013 - 5:20 pm
      Reply /

      not if you have already done it.

  5. cb  - 4 February , 2013 - 2:46 am
    Reply /

    Thanks. Wanted to point out a typo – “noval” instead of “novel” – in the introduction

    • bill  - 4 February , 2013 - 1:22 pm
      Reply /

      Thank you.

  6. optyler  - 12 February , 2013 - 12:49 am
    Reply /

    Thank’s a lot again, this post was realy usefull!

    SVN running very well since 1 month 😉

    • bill  - 12 February , 2013 - 10:57 am
      Reply /

      You are welcome, thanks for the nice words.

  7. Hans  - 18 April , 2013 - 10:35 am
    Reply /

    Thank you for sharing a nice article!

  8. Mike  - 21 July , 2013 - 4:56 am
    Reply /

    I get this error when restarting Apache

    AuthType not allowed here
    Action ‘configtest’ failed.
    The apache error log may have more information.

    When I checked the log, I see no information. Can some one please give some insight on this?

    • bill  - 31 July , 2013 - 6:17 pm
      Reply /

      When attempting to start the Apache server in the terminal the output would have displayed the file and line of the syntax error. Please check that you have edited it correctly.

  9. Joe  - 20 January , 2015 - 6:16 am
    Reply /

    If you want to enforce only SSL, just add


    inside the tag.

    Thank you very much again for the article !

    • Bill  - 20 January , 2015 - 6:18 pm
      Reply /

      Thanks, nice tip!

Leave a comment

Back to Top