Archive for the ‘Subversion’ Category

Guide To Installing the Subversion HTTP Module on Windows

Tuesday, September 20th, 2005

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.

Less Than Mere-Moments Installation of Subversion

Tuesday, September 6th, 2005

Inspired by Joe’s Mere-Moments Guide to installing a Subversion server on Windows, I have created an installer that will walk you through the steps that are required for installing Subversion on Windows. You can find my project here: http://svn1clicksetup.tigris.org. It still has room for some refinements, but it should make the installation process even easier. If you haven’t tried SVN yet, I would highly recommend doing so.