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:

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

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

    7. 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:

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

    3. 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:

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

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

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

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

    8. <Location /svn/>

    9. DAV svn

    10. SVNParentPath C:\repositories

    11. SVNListParentPath On

    12. Require valid-user

    13. AuthType Basic

    14. AuthName "Subversion repository"

    15. AuthUserFile bin/svn-passwd

    16. </Location>

  1. 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).

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

    2. LoadModule dav_module modules/mod_dav.so

    3. LoadModule authz_owner_module modules/mod_authz_owner.so

    4. LoadModule proxy_module modules/mod_proxy.so

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

    6. LoadModule dav_svn_module modules/mod_dav_svn.so

    7. 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:

    2. cd/d c:\

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

    4. svnadmin create svn

    5. 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).

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

    7. c:\svn\conf\passwd

    8. 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:

    9. smith = jones

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

    11. # 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)