How-To Geek

Install Subversion with Web Access on Ubuntu

This article covers installing subversion with the apache module so that it can be easily accessed from other systems on a public network. If you want a more secure svn server, you could use svnserve+ssh, which isn’t covered in this article.

To install subversion, open a terminal and run the following command:

sudo apt-get install subversion libapache2-svn

We’re going to create the subversion repository in /svn, although you should choose a location that has a good amount of space.

sudo svnadmin create /svn

Next we’ll need to edit the configuration file for the subversion webdav module. You can use a different editor if you’d like.

sudo gedit /etc/apache2/mods-enabled/dav_svn.conf

The Location element in the configuration file dictates the root directory where subversion will be acessible from, for instance:

<Location /svn>

The DAV line needs to be uncommented to enable the dav module

# Uncomment this to enable the repository,
DAV svn

The SVNPath line should be set to the same place your created the repository with the svnadmin command.

# Set this to the path to your repository
SVNPath /svn

The next section will let you turn on authentication. This is just basic authentication, so don’t consider it extremely secure. The password file will be located where the AuthUserFile setting sets it to…  probably best to leave it at the default.

# Uncomment the following 3 lines to enable Basic Authentication
AuthType Basic
AuthName “Subversion Repository”
AuthUserFile /etc/apache2/dav_svn.passwd

To create a user on the repository use, the following command:

sudo htpasswd2 -cm /etc/apache2/dav_svn.passwd <username>

Note that you should only use the -c option the FIRST time that you create a user. After that you will only want to use the -m option, which specifies MD5 encryption of the password, but doesn’t recreate the file.


sudo htpasswd2 -cm /etc/apache2/dav_svn.passwd geek
New password:
Re-type new password:
Adding password for user geek

Restart apache by running the following command:

sudo /etc/init.d/apache2 restart

Now if you go in your browser to, you should see that the repository is enabled for anonymous read access, but commit access will require a username.

If you want to force all users to authenticate even for read access, add the following line right below the AuthUserFile line from above. Restart apache after changing this line.

Require valid-user

Now if you refresh your browser, you’ll be prompted for your credentials:

You now have a working subversion server!

Lowell Heddings, better known online as the How-To Geek, spends all his free time bringing you fresh geekery on a daily basis. You can follow him on if you'd like.

  • Published 12/28/06

Comments (88)

  1. Nick

    Thanks for the great guide!

    Make sure you set the permissions of the /svn directory to apache with the following command:

    sudo chown -R www-data:www-data /svn


  2. Max Russell

    I actually set my Subversion directory up in my home directory, so it looks like:

    if I set the root directory from which Subversion can be accessed to /home/max/Projects, does this have any security implications for everything under the level of /home/max or will the browsable content when I get the subversion server hooked up to apache only be at the /Projects directory level?

  3. Philipp Keller

    Thanks a lot for this tutorial. Worked like a charm. You spared me some hours of figuring this out myself.

  4. Lane Roathe

    Thanks for the page. I wanted to add that if yo have a multi-repository setup you need to change




    or you will not be able to get access to your repositories.

    I’m using a setup similar to Max’s and have not seen any security implications so far, for what that’s worh.

  5. calenti

    Thanks so much – I have spent two days trying to get AlephZero’s version working and by following your instructions had it in 10 minutes.

    You aren’t just the HowToGeek – you’re the GoToGeek.

    Now can you tell me, is the Internet down? I tried to use my computer’s cup holder and it broke, can you get me a new one?


  6. Lorin


    Only thing I had to add was one line after the auth section:

    Require valid-user

    Else it doesn’t prompt for a password. Other than that, this how-to was very straight-forward and concise. Three cheers for SVN! =)

  7. Francesco Montorsi

    Thanks for this great & simple guide!
    The only thing I had to change was “htpasswd2” in “htpasswd” which is part of the “apache2-utils” package in my Gutsy install.

  8. Jörg

    Hallo & Thanks for this very good instruction. As mentined before by another one, after spending a lt of time in get things work, your explaination helped me to get it work in a few minutes.

    But one point differs in my Kubuntu 7.04 instalation. i only had htpasswd instead of htpasswd2 and i could not
    install another version !?! – But it works :-))

  9. Katrin

    cool – that went smoothly :)
    thank you.

  10. lautaro

    This works pretty well, thanks allot.
    The only problem that I had, was the command:
    “htpasswd2”, I solved it changed it by “htpasswd”


  11. Zeev Russak

    Please remember to uncomment the tag at the end of the configuration file.

  12. Eddy

    Hi, I’ve setup a subversion based on the above tutorial but honestly I am a little lost. My situation is that I would have a subversion and a couple of clients within LAN. Is that possible, let’s say the subversion server is at address while other clients are at 192.168.100~105.

    The error message I received when connecting client to svn server was “Error * can’t connect to host ‘’: No connection could be made because the target machine actively refused it.

    I am running ubuntu 7.10.

  13. Shan

    Very good instruction.


  14. Sanj

    Thanks mate, good one! :)

  15. Sanj

    @Eddy, can you connect to the server from locally from the server (as opposed to remotely from another computer)? You may have a firewall running which could prevent external access.

    You could also do a [sudo netstat -an | grep ‘:80’] to make sure you apache2 server is up.
    Make sure it is in LISTEN mode. If you’re running on another port, substitute the 80 with that port. To find out which port you are running apache2 on you can use [cat /etc/apache2/ports.conf]

    to start the apache2 server manually run [sudo /etc/init.d/apache2 restart]

  16. Neuquino

    How can I hide the version of subversion? I mean, that line: “Powered by Subversion version 1.3.2 (r19776)”
    That line has some security issues that I don’t want to deal with.

  17. Tim

    I had to use htpasswd for this all to work on my ubuntu gutsy gibbon box.

  18. Albo

    Wow.. I did this in Windows and took me half hour, here in ubuntu just did in 5 minutes.
    I used htpasswd too, and I forget to uncomment .

    Muchas gracias!

  19. arbingersys

    Excellent article and instructions. Got SVN up and running on a fresh server in no time.

  20. andrea

    hi , tanks for article!
    authentication seem not work for me. i have follow the guide but if i try from remote machine

    >svn co http://myServer/svn
    >cd svn
    >touch test
    >svn add test
    >svn commit

    it let’s my do without ask for a password.
    i want commit acces require username/password.
    how can i do?

    someone could suggest me a good web tracking/ticket sistem?

    sorry for my english.

  21. Brian

    I am having 403 forbidden errors… kUbuntu 7.10

    any idea’s? thanks…

  22. Vinidog

    I’m with the follow erros:

    sudo /etc/init.d/apache2 restart
    * Restarting web server apache2 Syntax error on line 16 of /etc/apache2/mods-enabled/dav_svn.conf:
    DAV not allowed here

  23. Raptor Ramjet

    Under Ubuntu Hardy Heron (8.04) the command “htpasswd2” seems to now be named “htpasswd” so the line should now read:

    sudo htpasswd -cm /etc/apache2/dav_svn.passwd

    After a quick 10 minute googling that worked for me.

  24. anon

    You realize that this is completely plain text, don’t you? Set up SSL.

  25. Raptor Ramjet


    Your problem is probably that the “” and “” directives are commented out. Remove the”#” at the start of the lines and it should work (I had the same problem)

    And I didn’t spot lautaros post when I added my tip yesterday… Ho hum…

  26. wildduck

    If you get this error when trying to import your projects from remote locations:

    svn: Can’t create directory ‘/srv/svn/projZ/db/transactions/0-1.txn’: Permission denied

    you need to allow import through http access:
    chown apache:apache -R /path/to/repo

    in ubuntu its
    chown www-data:www-data -R /path/to/repo

  27. Sayali

    Thanks for the wonderful guide!
    One observation: when using
    sudo htpasswd2 -cm /etc/apache2/dav_svn.passwd
    I encountered an error that I dont have htpasswd2. So I used htpasswd instead and everything else worked fine!
    Thanks again!
    — Sayali

  28. ramesh

    i have a subversion in ubuntu.please give the detail to install and configuration.

  29. Tarun

    Thanks for your instructions. Help me alot. but one confusion. what to do if i need to refer the domain like “http://svn.localhost”

  30. sooraj

    This was useful. I could setup the server in less than 10 min on an ubuntu box. The only thing missing was setting the ownership and permissions for the repository directory. I had to find that information from here:

  31. Christoph

    Thx for this short and helpfull howto. Works like a charme. As mentioned somewhere above, it is worth showing how to setup multiple repositorys in dav_svn.conf

    But thx a million

    /cheers Christoph

  32. Chris

    i have spent since tuesday morning trying to do the same thing on the spare mac we use as a server (OSX), got fed up and decided to try it on my linux machine that i work on…. done in 10 mins

    so come monday going to be talking my boss into getting a spare machine I can stick ubuntu on :D

    thx dude

  33. Jeff

    Thanks a bunch for this how-to, it really helped. All of the user comments on extras helped as well, so a thanks to them as well.

    If I might add a piece. Be sure to uncomment the following line at the end of /etc/apache2/mods-enabled/dav_svn.conf :


    If you don’t uncomment it, you get the following error:

    apache2: Syntax error on line 186 of /etc/apache2/apache2.conf: Syntax error on line 13 of /etc/apache2/mods-enabled/dav_svn.conf: /etc/apache2/mods-enabled/dav_svn.conf:13: /svn/ was not closed.

    Thanks again!

  34. Lars

    If you’re getting an xml error messge – try chaing SVNpath to SVNparentpath in the dav_svn.conf file. It helped me.

  35. Ted

    I’m getting this error when I try to restart apache:
    * Restarting web server apache2
    apache2: Syntax error on line 184 of /etc/apache2/apache2.conf: Syntax error on line 14 of /etc/apache2/mods-enabled/dav_svn.conf: /etc/apache2/mods-enabled/dav_svn.conf:14: was not closed.

    The lines that the msg is talking about are these:
    # …
    # URL controls how the repository appears to the outside world.
    # In this example clients access the repository as http://hostname/svn/
    # Note, a literal /svn should NOT exist in your document root.

    Any ideas on why it’s failing?

  36. Hektor

    Ted, I got the the same error.I’m sure you removed the # from the first instance of location
    You may not have noticed the ending location tag at the end of the file
    If you remove the # from this tag it should work for you.

    Great article. adding a comment about the second # tag would have made things clearer for me.

  37. Action

    Many thanks. Got there in the end.

  38. Ted

    Thanks! Removing the “#” front the closing tag at the bottom of the file did the trick.

  39. Ted

    I’ve got this working somewhat, but when I try to create a new directory in the repo, I get the message:

    “Can’t open activity db: APR does not understand this error code”

    Anybody have any idea why I’m getting this?

  40. Zack

    Hey, that all went smoothly except when I try to navigate to that URL, the 401 authorization fails…

  41. Pham

    @Ted: I also have the same problem with you. I don’t know why.

    “Can’t open activity db: APR does not understand this error code”

    Could anybody help us?

  42. Fabio

    I found that adding setting

    SVNListParentPath on

    helped with a

    You don’t have permission to access /svn


    Didn’t look into this any deeper, just my 2cts.


  43. John

    thanks for every one’s help. One thing I want to add is when restarting apache2 via:

    sudo /etc/init.d/apache2 restart

    and you get the error:

    * Restarting web server apache2
    Syntax error on line 16 of /etc/apache2/mods-enabled/dav_svn.conf:
    DAV not allowed here

    Make sure that you uncomment the very last line in the file: /etc/apache2/mods-enabled/dav_svn.conf
    That line is: #
    Remove the # and it should be:

    Save the file and restart apache2 again. It should work.

  44. John

    For some reason it did NOT pick up the line: It is the ” directive.

  45. eka

    i got this error when i access http://localhost/svn

    Could not open the requested SVN filesystem

    what should I do..?
    thx b4

  46. Ikonye Mwangi

    Thanks a lot for your tutorial. It really helped. Thanks to all those who dropped their comments. But it seems most guys(including me) are forgetting to remove the ‘#’ from ‘#’ closing tag and therefore getting errors. If possible include this in your tutorial.
    Thanks again.

    Regards GMwangi.

  47. Jagjot Singh

    Hi i could successfully install svn in ubuntu but opening the repo page in firefox 3 shows text instead of webpage. Where am i going wrong ?

  48. balcony

    My svn server already working but I can not do these following:

    1. auto checkout a folder with svn server every 5minutes
    2. View file uploaded to SVN server on computer that instal SVN server (view as my computer file on windows)

    Thanks for help

  49. Sourav Mohanty

    Thanks a lot for the reference. Great Post.

    Sourav Mohanty (Linux Lingo)

  50. Yamin

    Thanks a lot, it worked for me. :)

  51. Ankur

    Even after 3 years, your process works flawlessly :). Thanks!

  52. Mathan Kumar


    Thanks for your tutorial. This helps me a lot……

  53. PhyloGenesis

    I was getting the Forbidden error, and when I added the ShowParentPath it worked, however I discovered you shouldn’t be using ParentPath if you did svnadmin create /svn. (Remove ShowParentPath if you added it.)
    What I wanted was multiple repos within /var/svn so I did:
    mkdir /var/svn
    svnadmin create /var/svn/repo1
    svnadmin create /var/svn/repo2
    then with SVNParentPath set to /var/svn, I couldn’t access http://IP/svn but I could access http://IP/svn/repo1

    So I think the problem is you are using SVNParentPath but have /svn as a repository itself rather than the parent directory of other repos.

    Hope that helps.

  54. Gene

    I found if the apache2 user is different from your svn root user, you will have problem to write to the svn repo. Anyway, I have to do: sudo chown www-data:www-data -R /svnroot. FYI.

  55. Mayank Madhav

    Thanks a lot for the tutorial.Much of problem with the ubuntu community page was solved.That page mentions the changes to dav_svn.conf file without explaining the significance of each comment or tag in the file.
    This is far more lucid and simple explanation.

  56. sam

    Good steps, It works for me.
    But my question is, I have added one user to access my repos
    but What I want is to set multiple users and each one will have access to different project in repos. so no one can touch the other directory.

    can it be possible


  57. Kåre knall

    I followed the guide 100% but I am only getting this error when i try to access it

    Not Found

    The requested URL /svn/ was not found on this server.

    Apache/2.2.11 (Ubuntu) DAV/2 SVN/1.5.4 PHP/5.2.6-3ubuntu4.1 with Suhosin-Patch Server at Port 80

  58. Christian

    for the error

    Syntax error on line 16 of /etc/apache2/mods-enabled/dav_svn.conf:
    DAV not allowed here

    Make sure uncoomment the and tags =)

    great post

  59. kishore kumar datla

    Hi Zeev Russak, very thanks for your suggestion for uncommenting the last line….

  60. richard

    This article save me a lot of time to figure out what to do and poke around through Google. You really did a great job. Thank you.

  61. darshana

    while restarting the apache i’m getting..
    No apache MPM package installed
    so what do i do?

  62. Marko

    @ darshana

    Had the same “MPM…” problem.
    Took some time to find a solution.
    Finally solved it with:
    sudo apt-get install apache2

  63. olaf

    Hi there!

    Thanks too – and this still works with Ubuntu karmic :-)


  64. nico2884

    # dav_svn.conf – Example Subversion/Apache configuration
    # For details and further options see the Apache user manual and
    # the Subversion book.
    # NOTE: for a setup with multiple vhosts, you will want to do this
    # configuration in /etc/apache2/sites-available/*, not here.

    # …
    # URL controls how the repository appears to the outside world.
    # In this example clients access the repository as http://hostname/svn/
    # Note, a literal /svn should NOT exist in your document root.

    # Uncomment this to enable the repository
    DAV svn

    # Set this to the path to your repository
    SVNPath /svn
    # Alternatively, use SVNParentPath if you have multiple repositories under
    # under a single directory (/var/lib/svn/repo1, /var/lib/svn/repo2, …).
    # You need either SVNPath and SVNParentPath, but not both.
    #SVNParentPath /var/lib/svn

    # Access control is done at 3 levels: (1) Apache authentication, via
    # any of several methods. A “Basic Auth” section is commented out
    # below. (2) Apache and , also commented out
    # below. (3) mod_authz_svn is a svn-specific authorization module
    # which offers fine-grained read/write access control for paths
    # within a repository. (The first two layers are coarse-grained; you
    # can only enable/disable access to an entire repository.) Note that
    # mod_authz_svn is noticeably slower than the other two layers, so if
    # you don’t need the fine-grained control, don’t configure it.

    # Basic Authentication is repository-wide. It is not secure unless
    # you are using https. See the ‘htpasswd’ command to create and
    # manage the password file – and the documentation for the
    # ‘auth_basic’ and ‘authn_file’ modules, which you will need for this
    # (enable them with ‘a2enmod’).
    AuthType Basic
    AuthName “Subversion Repository”
    AuthUserFile /etc/apache2/dav_svn.passwd

    # To enable authorization via mod_authz_svn
    #AuthzSVNAccessFile /etc/apache2/dav_svn.authz

    # The following three lines allow anonymous read, but make
    # committers authenticate themselves. It requires the ‘authz_user’
    # module (enable it with ‘a2enmod’).
    #Require valid-user

  65. ankit

    thanxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx for all lines

  66. Henrique Duran

    Hello everybody,
    Must configure the same machine over a SVN repository, because I have here 2 different designs! (Example: / Project1 and / Project2) Here I have up and running to Project1, how do I configure Project2? and if possible would like to set users for each project

    Henrique Duran

  67. Nilesh

    Thanks for useful article.

    This command helps set correct permissions

    sudo chown -R www-data:www-data /path/to/svn

  68. Neil

    I just went through this very good (as usual) how-to and everything worked out as described. I followed the steps exactly and have also done the additional tips mentioned in the comments on Ubuntu 10.04.

    My only issue is that when I try to connect Dreamweaver CS5 (and I will admit I just started using it this week) on my Windows 7 machine and enter in the SVN details DW reports:

    “Server and project are not accessible! (The OPTIONS response did not include the requested activity-collection-set; this often means that the URL is not WebDAV-enabled)”

    I spent the last few hours trying to figure it out and I suspect that it may be an issue with DW as I can get to the repository page in my browser as described, but I am out of places to look at this point. Any suggestions would be great. Thanks in advance.

  69. Marcel

    Thanks, nice tutorial!!

  70. vadim

    Hi All, thanks for simple guide, everithing works fine for me on Ubuntu 10.4 except htpassvd2 changed to htpasswd.

    I have a question for now, I’ve created new svn repository for one project and it works fine, but later I’ll need to create another new repository for Ex: newrepo, could you help me with that please? thanks.

  71. Gulab Pasha


    I have an SVN server running on Ubuntu 10.04. Inside /svn, there are various projects – /svn/myproject1 and /svn/myproject2 etc. I want to be able to give user “A” full SVN permissions for ‘myprject1’, but not ‘myproject2’, and vice versa – user “B” could have permissions to ‘myproject2’ but not necessarily ‘myproject1’.

    What is the best way to do this?

    Please I’m new to svn…

    Gulab Pasha

  72. david


  73. Brian

    Need to uncomment #</Location> at the end of the file. Not sure why someone wanted to mix XML style syntax with a config file…

  74. Nadeem

    Greate, works like a charm, thanks v much !!!!

  75. Bas van Gaalen

    Besides some things you’ve missed to mention – and that were mentioned in the comments – this helped me setup svn in no time. Even now, so much later…

  76. Clayton

    Thanks for this. Just helped me out on ubuntu 10.04

  77. Joseph

    I connect to the repository http://myhost/snv/repos

    repos – Revision 0: /

    Powered by Subversion version 1.6.6 (r40053).

    But when trying to get a new project directory a get an error
    Subversion Repository
    Password for ‘joseph’:
    Authentication realm: Subversion Repository
    Username: svn
    Password for ‘svn’:
    svn: Repository moved permanently to ‘http://myhost/svn/repos/’; please relocate

    Any suggestion will be greatly appreciated.


  78. vijayanand

    I got an error,i am a newbie and i can’t correct this…

    root@bwss:~# sudo /etc/init.d/apache2 restart
    Syntax error on line 20 of /etc/apache2/mods-enabled/dav_svn.conf:
    AuthName takes one argument, The authentication realm (e.g. “Members Only”)
    Action ‘configtest’ failed.
    The Apache error log may have more information.
    content i enter in my file


    DAV svn
    SVNPath /svn
    AuthType Basic
    AuthName “Subversion Repository” —>this is line 20
    AuthUserFile /etc/apache2/dav_svn.passwd


  79. Jan

    @vijayanand maybe you forgot to UNCOMMENT also the AND TAG

    this was also my failure

    I didnt get SVN running with the config in /var/www/vhosts/

    so I take the /etc/apache/enabled-mods/dav_svn.conf and uncommented these lines

    DAV svn
    SVNParentPath /PathToRepository/svn
    AuthType Basic
    AuthName “Subversion Repository”
    AuthUserFile /PathToPasswdFile/dav_svn.passwd

    (was jiggling countless hours.. :-) )

  80. José

    Help !

    After i finished the steps i get :

    No apache MPM package installed

  81. José

    this post resolved the probelme

    Hum… the “/etc/init.d/apache2” script has this stanza:

    set -e
    if [ -x /usr/sbin/apache2 ] ; then
    echo “No apache MPM package installed”
    exit 0

    So try to locate your apache2 binary with “whereis apache2”.

  82. Prashant

    How to solve this problem when i restart the apache2
    sudo /etc/init.d/apache2 restart
    No apache MPM package installed

    Plz Help me

  83. José


    This should do the trick :

    sudo apt-get install apache2-mpm-worker

  84. NewUser

    I get the error E: Could not get lock /var/cache/apt/archives/lock, how can I resolve the error??

    Please help…

  85. inspectorG4dget

    Many thanks @Jeff. I had this exact problem, and you fixed it.

  86. ajay

    why do i get Error Code 2
    Could not open the requested SVN filesystem

  87. ajay

    i installed apache2 and svn as mentioned above.
    But i keep getting

    Could not open the requested SVN filesystem

  88. chris

    Solved the Problem:
    I’m with the follow erros:

    sudo /etc/init.d/apache2 restart
    * Restarting web server apache2 Syntax error on line 16 of /etc/apache2/mods-enabled/dav_svn.conf:
    DAV not allowed here

    Remove the ‘#’ from the start and ending of the Location Tags

More Articles You Might Like

Enter Your Email Here to Get Access for Free:

Go check your email!