Guide To Installing the Subversion HTTP Module on Windows

After creating an installer to assist with setting up Subversion repositories on Windows, I started wondering how hard it would be to make a repository visible through HTTP. When comparing the different server configurations in the Subversion book they say that the HTTP server is “somewhat complex” to set up. Despite the warning that it was complex, I proceeded to get a repository up and running within a couple of hours (although it took me longer when I walked through my steps to write this guide for some reason). I thought that I would share my experience, and hopefully this guide will assist those you who would like to be able to use Subversion through HTTP.

  1. Download the binaries

    Go to the Apache download page and download the latest version of their web server. As of the writing of this article it was 2.0.54.

    Go to the Svn1ClickSetup download page and download the latest version. As of the writing of this article it was 0.8.3.

  2. Set up Subversion

    Run the Svn1ClickSetup executable downloaded in the previous step. When I refer to installation locations later in this guide, I will be assuming you installed everything in their default locations. If you install anything in a different directory, you will need to make the necessary adjustments.

    Note: Svn1ClickSetup installs a Subversion service, if you don’t want to be running this service, open a command prompt, and run the following command:

    svnservice -remove

  3. Install Apache

    Run the Apache installer that you downloaded. I had never installed Apache before, but the defaults worked fine for me.

    Once the installation finishes, launch a web browser, and browse to http://localhost. If you see a test page from Apache, the server is installed correctly.

  4. Set Up HTTP Access

    The first thing we need to do is make sure that Apache loads the WebDav modules. The Apache config file (httpd.conf) is located in the C:\Program Files\Apache Group\Apache2\ conf directory. Launch a text editor, and open the Apache config file. You will want to keep this file open for the rest of the installation.

    Copy the Subversion HTTP module (Program Files\Subversion\bin\mod_dav_svn.so) into the Apache modules directory (Program Files\Apache Group\Apache2\Modules).

    In the config file, look for a section of lines that all start with LoadModule. At the end of that section, add the following lines:

    LoadModule dav_module modules/mod_dav.so
    LoadModule dav_svn_module modules/mod_dav_svn.so
    

    At this point, restart the Apache2 service (Control Panel > Administrative Tools > Services). You will probably want to keep the Services window open (we will be restarting Apache several more times). If it restarts with no errors, Apache is now loading the SVN module.

    Back in the Apache config file, add the following to the end of the file:

    <Location /repos>
      DAV svn
      SVNPath "C:\svnrepos"
    </Location>
    

    Restart Apache2 again, and if it restarts successfully, go ahead and pat yourself on the back. You can now access your repository via HTTP (that wasn’t so bad, was it?)

  5. Configuring Authentication

    One small note before we start looking at authorization. There are several different ways you can configure authorization for Subversion, but I am only going to show you basic authorization in this guide. Basic authorization sends the passwords in near plain-text, so if you are concerned with password snooping, you will want to use a different authorization scheme.

    At this point, we can browse our repository via HTTP. Not only that, but we can also check-out, modify, and commit changes. However, none of these operations require any type of authorization. Not exactly what we want, especially if we are going to have multiple users.

    To enable authorization, we need to tell Apache who the authorized users are. To do this, we give Apache a file with a list of the authorized users and their passwords. Apache makes this job easy by providing a utility to mange the user file, htpasswd.

    Let’s go ahead and create our user file with the users Alice and Bob. We are going to put our file in the Apache conf directory, so open a command prompt to that directory (Program Files\Apache Group\Apache2\conf). Type the following command, and then enter a password for Alice.

    C:\Program Files\Apache Group\Apache2\bin\htpasswd -cm svn-auth-file Alice

    Now type in the following command to add Bob to the file.

    C:\Program Files\Apache Group\Apache2\bin\htpasswd -m svn-auth-file Bob

    Notice the difference between these two commands. The first command passes in the -c command, which tells htpasswd to create the file. The second time, the file already exists, so we don’t want it to be re-created. The second command is what you would use to add additional users to the file. If you look at the svn-auth-file, you will see entries for both Alice and Bob.

    Now that we have our authorization file, we need to tell Apache where to look for it. Go back to the Location tag that we added to the Apache config file. We need to add some more lines to it so that it looks like this

    <Location /repos>
      DAV svn
      SVNPath "C:\svnrepos"
      AuthType Basic
      AuthName "Subversion repository"
      AuthUserFile "C:\Program Files\Apache Group\Apache2\conf\svn-auth-file"
      Require valid-user
    </Location>
    

    After restarting Apache2 once again, browse to your repository again. This time, you will be prompted for a user name and password. Cool, we have authorization working. However, I don’t want to be prompted for a user name unless modifying the repository, so we’re not quite finished yet.

    Thankfully, only requiring authorization for modifications is really easy. All we have to do is add a couple more lines to our location tag so that it looks like this

    <Location /repos>
      DAV svn
      SVNPath "C:\svnrepos"
      AuthType Basic
      AuthName "Subversion repository"
      AuthUserFile "C:\Program Files\Apache Group\Apache2\conf\svn-auth-file"
      <LimitExcept GET PROPFIND OPTIONS REPORT>
        Require valid-user
      </LimitExcept>
    </Location>
    

    One last restart of Apache, and we now have the Subversion HTTP module installed, configured, and ready to control our revisions.

22 Responses to “Guide To Installing the Subversion HTTP Module on Windows”

  1. Michael Hansen says:

    Dude! You are my hero… Thank you so much for the installer and this tutorial :o) If there were more people like you, Open Source would rule the world :o)

    Cheers

    -michael

  2. Thanks a lot for your tutorial.
    I’ve just have a problem to activate the WebDav support:
    Apache was unable to load the mod_dav_svn.so module.
    To workaround this, I’ve use the Dependancy Walker to lookup the the needed dll (as suggested in the Subversion FAQ) and copied these dll in the Apache modules folder:
    intl3_svn.dll, libapr.dll, libapriconv.dll, libaprutil.dll, libdb43.dll, libeay32.dll, libhttpd.dll, ssleay32.dll.
    Part of these dll are located in the Apache bin folder and the other in the Subversion bin folder.
    This seems to tricky, so let us know if there is a way to install the bundle without this problem.

    Regards,

    Eric

  3. Brian says:

    Eric,
    The easiest way to get around this problem is to make sure that the subversion bin directory is on your PATH environment variable. Is it is, Apache should be able to load all of the other dlls.

    Brian

  4. Thanks Brian,

    I’ve added the Subversion bin directory in my PATH environment variable, but it seemed to not solve the problem.
    However, after rebooting my PC (XP SP 2) and removing the dll I previously copied, every thing runs as expected.

    Regards,

    Eric

  5. [...] I started out reading Brian’s guide to installing everything. Now, I didn’t use his one-click installer, but I followed the rest. Notably, I believe the system account on our server didn’t pay attention to the path I had set system-wide, as it could not load the Subversion modules unless I gave it absolute paths for everything. But I got that working. It was interesting to note that when I had Apache installed, the Subversion installer actually offerred to install and configure the modules for me. I had Subversion access through HTTP. [...]

  6. Jay says:

    This tutorial is great. Thanks a lot for writing it. My only change was I used Netserver, a pack of servers for Windows NT/2000/XP with a gui controller. It worked without a hitch, the first time.

    http://netserver.hugosoft.net/

  7. Glitsj16 says:

    Thx for another great tutorial, although correcting the spelling in the URL and title would make your howto easier to track down in search engines … ;) Cheers!

  8. Andrew Blackburn says:

    Hugely helpful! Accomplished in ten minutes what I couldn’t get done in ten hours! Thanks!

  9. subash joseph says:

    Dear Brian,

    I installed SVN 1.3.1 and Apache Sever.Is it possible to give any authorization in folder level in the repository.what changes needed for that.

    Please help me.I am in trouble

    subash

  10. el turco says:

    Thanks for this tutorial! I wanna tell you the problem where I get stucked.

    If someone has the following error message:
    mod_dav_svn.so is garbled - perhaps this is not an Apache module DSO?

    Here is a possible solution:
    Apache 2.2 is compiled with a version of Visual Studio which is not compatible with the Subversion build. Use Apache 2.0 and the Subversion modules will work.

    I found this at http://www.subversionary.org/howto/setting-up-a-server-on-windows

  11. Barclay says:

    That solution for “mod_dav_svn.so is garbled” problem isn’t real solution, as Apache 2.0+SVN is broken too (at least for Linux servers). The only known for me solution at a moment of this writing is to downgrade to the latest stable combination of apache+svn+neon, which use apr:0 (0.9x) (not apr:1)

  12. Nice. Just what i was looking for. Thanks

    NC Tech Support Team
    Brian Nailer

  13. Jason says:

    Regarding the “mod_dav_svn.so is garbled” problem:

    The version of Subversion that is installed currently with oneclick is not compatible with Apache 2.2. If you go to subversion.tigris.org you will see there is now a choice to download binaries compiled against apache 2.2. You can download this zip file and overwrite your Program Files\Subversion folder with the new versions. Then re-copy the .so module files.

  14. Kyle says:

    Many thanks for putting this together! Saved me a ton of pain.

  15. Matt says:

    Took me a little over an hour because I grabbed the latest version of everything.

    Found out that you have to use Apache 2.0, with Subversion 1.3. Tried Apache 2.2, but the Subversion modules were compiled with Apache 2.0, so when I pulled them over, got a config error from Apache. Didn’t have the tools to re-compile the modules.

    Found this:
    http://svn.haxx.se/users/archive-2006-09/0526.shtml

  16. Anil Desai says:

    Here i installed subversion and apache. both are working fine. i made some changes in httpd file for user access. here as ur blog this will work for only one repository but i want many repository and not all users access all repository i want to give some restriction on each repositor. so pls guide me.

  17. I couldn’t get SVN 1.4.5 + Apache 2.2.8 working
    “mod_dav_svn.so is garbled” issue wasn’t sorting out
    Jason’s suggestion couldn’t do.

    However Apache 2.0.63 + Svn1ClickSetup-0.8.6 did the job.

    -Nishant

  18. 'ILLEGAL says:

    None…

    None…

  19. Ram says:

    Awesome!!! thanks

  20. hari says:

    HI,
    Every thing works fine, but when i am browsing the repository

    it is giving an error

    Could not open the requested SVN filesystem [500, #22]

    Please help on this

  21. andry says:

    EL7Vaf comment1 ,

  22. Nils A says:

    Thanks for this. I used this together with the Bitnami Subversion Stack, an all-in-one installer, available for all platforms including Windows. I had SVN up and running very quickly.

Leave a Reply