Subversion over Apache 2 on Ubuntu

If your one of my regular readers (ha!), then you’ll know I’m starting a Group Project for University. We have 7 members in the group and without some sort of version control – managing the code we’re about to produce would be hell! So I’m setting up Subversion on my home server as a repository. Following are the steps I used to set-up Subversion over Apache 2 on my Ubuntu server.

I’m assuming you have Apache 2 already set-up. The only extra packages to download and install are subversion and libapache2-svn.

sudo apt-get install subversion libapache2-svn

This will download and install Subversion and the SVN module for Apache 2. The module itself uses WebDAV to transmit files between Subversion – so this means everything can go across port 80 without the hassle of having to worry about a firewall.

The install should automatically enable the module, but just to check:

sudo a2enmod dav_svn

It should come up saying it’s already enabled. If not, it will enable it for you.

You’ll need to configure Apache now:

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

Edit the file to look something like this:

<Location /svn>
  DAV svn
  SVNPath /home/svn

  AuthType Basic
  AuthName "Subversion Repository"
  AuthUserFile /etc/apache2/dav_svn.passwd
  Require valid-user
</Location>

Change /home/svn to whatever the location of your repository is. If you haven’t created one yet, then do:

sudo mkdir /home/svn
sudo svnadmin create /home/svn

Now, you need to make Apache the owner of the repository:

sudo chown -R www-data /home/svn

To secure Subversion, do the following to create a password file:

sudo htpasswd2 -cm /etc/apache2/dav_svn.passwd bob

Replace bob with whatever username you want to use, and then when prompted enter a password.

Now restart Apache:

sudo /etc/init.d/apache2 restart

That should now all be set-up. You can try it by visiting your server http://you.server/svn. You should get a username/password dialog which you enter the details you created.

2006-02-16 [, , , ]

Comments

  1. So i have a problem, when i look if the module is enabled it’s says that ita cant find the module. And i have already installed everything. so please can yuo explain for me whats the problem?

    Stavros (2006-12-01 @ 11:00)
  2. Great tutorial – got apache2 and subversion up and running. :) Thanks!

    My only problem is if I install any kde based subversion client (kdesvn for example), Adept or even apt-get will install libsvn0 which is a different version from the latest subversion I compiled. And then if you do a “svn –version” – you get some error message about conflicting versions of svn.

    Do you know how to suppress the package managers from installing libsvn0? That is, have them recognize the compiled install?

    Thanks, Joe

    Joe (2007-02-25 @ 06:47)
  3. [...] Links: Setup a Subversion server in 4 minutes, Subversion over Apache 2 on Ubuntu. [...]

    geek » Configurando um servidor SVN sobre o Apache em poucos minutos (2007-03-14 @ 19:53)
  4. [...] References: Source svnsync.txt [...]

    Setting up a SVN 1.4 server using Apache 2.2 on Ubuntu « Ajo Paul (2007-03-30 @ 16:01)
  5. I tried it all the day but now i did it with your help. Thx

    oEGONo (2007-03-30 @ 20:57)
  6. Now that is the way a howto/tutorial should be written. Excellent job!

    jhanson (2007-06-07 @ 18:48)
  7. thx !!

    i had to use htpasswd (without the 2) tho.

    jorik808 (2007-06-11 @ 02:43)
  8. Thanks, nice tutorial

    Diego (2007-06-20 @ 10:17)
  9. [...] Subversion over Apache 2 on Ubuntu [...]

    SeBlog » Blog Archive » Hilfreiche Links für die Installation von Subversion (SVN) (2007-06-20 @ 22:52)
  10. excellent write up…. thanks for saving me so much time :)

    anuj (2007-07-20 @ 14:07)
  11. Thanks a lot!

    kos-mos (2007-07-26 @ 09:49)
  12. Spot on, thanks!

    (P.S. I used htpasswd not htpasswd2. Is this a typo?)

    Phil Wieland (2007-08-01 @ 15:41)
  13. Great help! Saved me hours and hours of work!

    Viktor (2007-08-21 @ 00:29)
  14. Thanks man, you rock!

    Phil (2007-10-03 @ 03:57)
  15. Whoa. Had I known Subversion was this easy, I would have migrated from CVS a long time ago.

    :-)

    Thanks, David. You did an excellent job on the tutorial too.

    Rick S. (2007-10-19 @ 21:37)
  16. Thank you and well done. Up and running in a matter of minutes!

    Paul R. (2007-10-27 @ 13:37)
  17. It worked great for me too. Very well done. Thanks.

    Bryan (2007-10-27 @ 16:52)
  18. Thanks for the great tutorial! I got this successfully working with a Feisty Ubuntu Server box. (also using htpasswd instead of htpasswd2)

    Kit (2007-11-06 @ 01:34)
  19. [...] Subversion over Apache 2 on Ubuntu http://davidwinter.me.uk/articles/2006/02/16/subversion-over-apache-2-on-ubuntu/ [...]

    Sucess: Subversion, apache2, SSL, ubuntu 7.10, with users « LinuxHappy’s Weblog (2008-01-21 @ 06:28)
  20. Another satisfied customer here. Many thanks for the tutorial.

    davo (2008-03-10 @ 00:13)
  21. Hi

    Very well done. Thanks.

    How do I add more then one user (bob)?

    I used following command to add 3 user, but its overwrite the existing user :(

    / Thava

    Theva (2008-03-10 @ 10:07)
  22. Wow. Nice job – to the point, rather than “gee – look how complicated this is, and how smart I am to have worked it out.”

    Should be more like this. Again – nice job – thx for the help

    Paul (2008-03-16 @ 23:43)
  23. Thank you. Well written tutorial!

    vj (2008-03-21 @ 01:42)
  24. Wow, you did a great job writing this tutorial. It’s very clear and concise. Thanks!

    James (2008-03-28 @ 18:28)
  25. Excellent tutorial. Simple, easy and everything that I needed. Importing a project was another story. We live and learn. Thanks for getting me started.

    Ulysses (2008-04-03 @ 03:26)
  26. I’m doing this, but am still receiving a forbidden 403 error when i browse the repository. I didn’t skip the chown step – they’re all the proper users, and groups. Any ideas?

    Ryan (2008-04-09 @ 00:22)
  27. Works Great! Thanks a lot.

    Carlos Bendfeldt (2008-04-16 @ 20:55)
  28. Thanks a lot, it was just great to use your description…

    Stefan (2008-04-22 @ 15:04)
  29. nuff said, awesome job!

    Evan (2008-06-19 @ 19:14)
  30. Thanks for such a wonderfull tutorial. i have a question. what to do if i want to refere my svn like “http://svn.localhost”.

    do i need to setup something with me apache configuration.

    Tarun Kumar (2008-06-29 @ 21:04)
  31. I used htpasswd instead of htpasswd2

    I ran my svn server on hardy and it now works!

    Thanks dude!

    Racumin_Baby (2008-07-03 @ 08:29)
  32. Great how-to! I spent a long time trying to get this setup, and this one only took 5 minutes! Thanks.

    Alex Bird (2008-07-15 @ 03:21)
  33. [...] cablop on Nov.04, 2008, under Apache 2, SVN, Ubuntu Este post esta basado en este Subversion over Apache 2 on Ubuntu, en [...]

    Como configurar Subversion (svn) en Apache 2 sobre Ubuntu - Orca Software Tips (2008-11-04 @ 15:46)
  34. Thanks. Had to use htpasswd instead of htpasswd2 though.

    Vinay Veldore (2009-01-16 @ 09:48)
  35. Add to the chorus – the simple steps (and functioning result) are a testament to a well written tutorial. cheers.

    James (2009-01-23 @ 16:04)
  36. when i try to acccess my svn server it says:

    This XML file does not appear to have any style information associated with it. The document tree is shown below.

    Could not open the requested SVN filesystem

    what did i do wrong?

    yugan (2009-03-16 @ 20:52)
  37. It is a nice tutorial. And I followed all the directions shown in this tutorial.I do not know why I am facing this error. Can you please help me out?

    Could not open the requested SVN filesystem

    Thanks Sachin

    Sachin (2009-04-09 @ 01:55)
  38. I do not know what happened to my last post.I think I forgot to write my error.When I do http://127.0.0.1/svn.I get the following error. Could not open the requested SVN filesystem

    Thanks Sachin

    Sachin (2009-04-09 @ 01:58)
  39. thx, it works.

    erenon (2009-04-17 @ 15:44)
  40. Thx, this worked for me.

    I had trouble connecting Eclipse 3.2.2 / ubuntu 9 to SVN using the SVNParentPath directive. Then I get: 301 permanently moved. The SVN commandline worked though.

    With the SVNPath directive I can connect Eclipse to my repo.

    Rollantz (2009-05-08 @ 09:31)
  41. On Ubuntu 9.04 I had to use sudo htpasswd -cm /etc/apache2/davsvn.passwd greg instead of sudo htpasswd2 -cm /etc/apache2/davsvn.passwd greg for that step. thanks!

    greg (2009-05-12 @ 03:42)
  42. I made an article based on this one in spanish, first a placed it at ORCA Ingeniería website. But as their Software Tips blog is not currently available, I’m publishing this guide again at my own website.

    http://softwaretips.cablop.net/index.php/2009/05/20/como-configurar-subversion-svn-en-apache-2-sobre-ubuntu/

    ?? (2009-05-21 @ 03:24)
  43. Una versión en español de esta guía está disponible en mi sitio en:

    http://softwaretips.cablop.net/index.php/2009/05/20/como-configurar-subversion-svn-en-apache-2-sobre-ubuntu/

    cablop (2009-05-21 @ 03:26)
  44. Works grate!! Tks

    zaracato (2009-07-12 @ 00:29)
  45. [...] post esta basado en este Subversion over Apache 2 on Ubuntu, en [...]

    cablop.net – Software Tips » Como configurar Subversion (SVN) en Apache 2 sobre Ubuntu (2009-08-29 @ 16:42)
  46. Awesome tutorial… exactly what I needed.

    Many thanks M8!

    snowdog99 (2009-09-03 @ 22:00)
  47. Thanks for this lovely article, it worked perfectly for me. Thanks for sharing :)

    Helen Hunt (2009-09-11 @ 21:01)
  48. I followed this tutorial. However when I run, http://localhost/svn/ I get the following error. any idea, what I need to do?

    Could not open the requested SVN filesystem

    ahsan (2009-12-14 @ 01:46)
  49. I followed this to the letter, I can co and commit, however it does not prompt me for a password, so I think it is wide open. What did I do wrong?

    Thanks….

    Michael Browning (2010-01-28 @ 21:46)
  50. THIS IS HOW YOU write a tutorial ! ! precice instructions and easy to follow

    Anant Asthana (2010-02-07 @ 22:53)

Powered by WP Hashcash