Installing/Setting up Subversion on Windows

2008-09-04
I'm here installing Subversion 1.5.2 (SVN) on Windows 2000 Server. First tried setting it up with Apache but after failing to do so because of some permission issue, and hearing that there at least in the past have been issues with WebDAV, particular about security, and finding out that Apache is not at all needed, I skipped the whole Apache part. The backdraw is that you cannot use Windows authentication for your svn users.

This tutorial is based on Team System - Setting up a Subversion Server under Windows - credit goes to them. My tutorial differs in that I'm setting up the Windows service using the native support from svnserve.exe for doing so instead of using a wrapper (supported from version 1.4 - see link above for further details). Also I have not set up SVN_EDITOR environment variable because I will never use the server itself to commit stuff (If you don't understand this, never mind, you don't need to!).

Please send me any comments or suggestions about this tutorial!

Install Subversion Download the latest version from http://subversion.tigris.org/ and copy content of zip files to somewhere, eg. under c:/Program Files/Subversion/.
Add directory to environment variable "path"

Add path to the bin folder to the environment variable PATH.

I had to restart the computer for this to take effect.

Create repository root folder The next step is to create a directory which will be a root for all the repositories of our source control. Eg. create the directory c:\svnroot
Create a test repository
  1. Create repositories in the svn root directories using the following commands:
    svnadmin create c:\svnroot\test1
  2. Navigate to the folder we just created. Within that folder, uncomment the following lines in the /conf/svnserve.conf file:
    [general]
    anon-access = read
    auth-access = write
    password-db = passwd
    

    Set anon-access to none instead if you won't allow public access to the repository.

  3. Next, uncomment these lines in the /conf/passwd file:

    [users]
    harry = harryssecret
    sally = sallyssecret

If you are told that MSVCP60.DLL is missing, you can download it from http://www.dll-files.com/dllindex/dll-files.shtml?msvcp60 and put it in your c:\windows\system32 folder.

To run Subversion as a daemon

Running Subversion as a daemon means that you have to log on to Windows and start the daemon (program) through the command line. That will bring up a windows running undefinitely. The command is:

svnserve --daemon --root "c:\svnroot"

Run this command to create a folder in the test repository to see if everything is working fine so far:

svn mkdir svn://localhost/test1/dir1 --message "This is my first checkin!"

You'll now be prompted for credentials. In my case I was prompted for the administrator credentials as well:

Authentication realm:  0f1a8b11-d50b-344d-9dc7-0d9ba12e22df
Password for 'Administrator': *********
Authentication realm:  0f1a8b11-d50b-344d-9dc7-0d9ba12e22df
Username: testuser1
Password for 'testuser1': ************

Committed revision 1.

Congratulations! You just checked a change into Subversion!

To run Subversion as a Windows service

Running Subversion as a Windows service means that it starts up automatically at boot time, you don't have to log on to the computer for it to run, and it runs nicely in the background. Note that only the newest versions of Subversion support natively running as a Windows service. Before version 1.4 you had to use a Windows service wrapper to imitate this. Read more about that here.

To install the service we use a command-line tool named SC.EXE. It is from the Windows Installer SDK (or Microsoft link) and is documented very nicely here. For Windows 2000 you can download it here.

The full command to install Subversion as a Windows service is:

sc create svn binpath= "\"c:\Program files\Subversion\bin\svnserve.exe\" --service
-r c:\svnroot" displayname= "Subversion Server" depend= Tcpip start= auto

Put all this on one line with a space between the two lines. Replace the path to svnserve.exe with the path to where you installed Subversion - and also the svn root folder if you put it somewhere else. Be careful to include the space after the equal signs (=).

When installed, start it by going to Control Panel -> Administrative Tools -> Services and right-click to Subversion Server service and select Start.

Set up the shell extension (TortoiseSVN)
  1. Run the TortoiseSVN installer. You can do this on another computer if you want to. It will tell you to restart, but you don't need to.
  2. Create a project folder somewhere on your hard drive. Right click in that folder and select "SVN Checkout..."
  3. If you are running TortoiseSVN on the same computer as you installed SVN server on, write this as for the URL of repository svn://localhost/test1/
  4. If you are running TortoiseSVN on another computer, replaced localhost with the IP, computer name, or domain for the server, eg. svn://80.161.54.98/test1/
  5. Click OK.
  6. Create a new file in that directory. Right click the file and select "TortoiseSVN", then "Add".
  7. The file hasn't actually been checked in yet. Subversion batches any changes and commits them as one atomic operation. To send all your changes to the server, right click and select "SVN Commit".
Done!

And we're done! You now have a networked Subversion server and client set up on your machine. Note that the default port for svnserve is 3690. Accessing the server from computers outside your firewall probably require that you open this port in your firewall. Google "open port in firewall" if you need help with that and consult your router manual.

Remember to set up backup of your repositories using either dump or hotcopy command of svnadmin.

As said in the beginning, most of the credit here goes to Team System - Setting up a Subversion Server under Windows.

References