Windows‎ > ‎Windows Server‎ > ‎

Subversion Cheat Sheet

Installing Subversion on a Windows Server

Subversion is a great source code control system. It is fast, reliable, and provides great flexibility on the files and directories which it can manage, including the ability to allow control via HTTP. So after having installed the Apache HTTP Server in order to allow the Subversion server to host files via HTTP, proceed as follows to install and configure Subversion.

Environment

Prerequisite Information

Before installing Subversion, gather the following information:
  1. The port number that Subversion should listen on: 3690

  2. The main Subversion repository path: c:\svn

  3. The Apache host name: localhost

  4. The Apache port number: 81

  5. The repository path for mod_dav_svn: c:\svn

  6. The repository URL prefix: /svn

Installation

  1. Download the installer program and run it.

  2. In the Welcome screen, click the Next button.

  3. In the Readme screen, click the Next button.

  4. In the Choose Components window, be sure that SVNSERVE and Apache (MOD_DAV_SVN) are selected, then click the Next button.

  5. In the Configuration window, enter the port number and main repository path. Also make sure the Install svnserve to run as Windows service option is selected. Then click the Next button.

  6. In the Apache Configuration window, enter the requested information. Be sure that the Install Apache to run as a Windows service option is selected. Then click the Next button.

  7. In the Install Location window, specify where Subversion should be installed, then click the Install button.

  8. Click the Finish button.

Post-Installation Tasks

Ensure that Subversion is installed properly with this command:

svn --version

Add the Subversion port to the Windows Firewall.
  1. Run Windows Firewall (StartControl PanelWindows Firewall).

  2. Click the Allow a program or feature through Windows Firewall link.

  3. Click the Allow another program button.

  4. In the Add a Program window, click the Browse button and locate the Subversion executable, usually located here:

    C:\Program Files (x86)\CollabNet\Subversion Server\svnserve.exe

  5. In the Add a Program window, click the Add button.

  6. Subversion Server should now be listed in the exceptions list of allowed programs and have a check-mark next to its name. Click the OK button in this window.
The Subversion server distributed by the CollabNet people has the Apache HTTP server bundled into it (and is now installed on your system if you followed the directions above). I have read their rationale for doing this but do not agree that a separate copy of Apache is necessary (desireable) to run Subversion so here’s the steps to now undo the Apache server installation performed by their installer and hook Subversion into your already installed Apache server.
  1. Go to the Apache modules directory installed by the Subversion server, typically here:

    C:\Program Files (x86)\CollabNet\Subversion Server\httpd\modules

  2. The two Subversion modules named mod_authz_svn.so and mod_dav_svn.so should be copied to the standard Apache modules directory, typically located here:

    C:\Program Files (x86)\Apache Software Foundation\Apache2.2\modules

  3. Open the standard Apache httpd.conf file with a text editor, which is usually located here:

    C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf

  4. Add the following lines to the end of the file (if they are not already there):

    <Location /svn/>
    DAV svn
    SVNParentPath C:\repositories
    SVNListParentPath On
    Require valid-user
    AuthType Basic
    AuthName "Subversion repository"
    AuthUserFile bin/svn-passwd
    </Location>

  5. Be sure to change the SVNParentPath and AuthUserFile entries to point to your repository directory and also be sure that the location is set to /svn/ and not just /svn (note the trailing slash).

  6. Check and make sure that the following LoadModule lines are uncommented (do not begin with a # character):

    LoadModule dav_module modules/mod_dav.so
    LoadModule authz_owner_module modules/mod_authz_owner.so
    LoadModule proxy_module modules/mod_proxy.so

  7. If it is not already there, add the following line to the end of the LoadModule section:

    LoadModule dav_svn_module modules/mod_dav_svn.so

  8. Rename the httpd directory from step 1 to something like httpd-do-not-use.
If you do not already have a password file set up for your Subversion users then create one now. Change your directory to the the Apache bin directory:

cd/d C:\Program Files (x86)\Apache Software Foundation\Apache2.2\bin

Then enter this command to create the user jsmith:

htpasswd -c svn-passwd jsmith

and type in the password for user jsmith when prompted. If you already have a password file and would just like to add another user to it (or change an existing user’s password) use this command instead:

htpasswd svn-passwd jsmith

Configuration

Create the Subversion repository.
  1. Set your default directory to the parent directory which you would like to create your repository in. For example, if your repository will be in the directory c:\svn then use this command:

    cd/d c:\

  2. Use the svnadmin command to create the repository directory. For example:

    svnadmin create svn

    Note: The last parameter (svn, in this example) should be the name you wish to give to the repository (i.e., the subdirectory of your current directory).

  3. A password file for the repository is created in the conf subdirectory of the repository’s directory. For example:

    c:\svn\conf\passwd

  4. Edit the password file with a text editor and add user accounts and passwords. For example, to add the user smith with a password of jones add this line to the end of the file:

    smith = jones

  5. Also in the conf directory, edit the file svnserve.conf and uncomment the following line:

    # password-db = passwd
Start the Subversion Server service.
  1. Start the service control manager (StartAdministrative ToolsServices).

  2. Locate the entry named CollabNet Subversion svnserve, right-click on the name, and select Start.

Next Steps

  • Install TortoiseSVN. (Use _svn for directories.)

References

  1. HOWTO: Subversion for Windows with Apache server - a beginner's guide
  2. How to set up Subversion with Apache in Windows (quick reference)
Comments