Running Subversion as a Windows Service

One thing programmers and software engineers know for sure (or at least should know) is that it doesn’t really matter how much time you spend on documenting, designing or keeping code clean: things may break and often will break. That’s a possibility that must be considered when working on an important project. Things get even worst when more than one person is working on the same stuff. Luckily, there is something we can count on to sleep peacefully: Subversion (SVN Wikipedia Page), a version control system.

This guide aims to help you configure a Subversion server on your Windows machine, running it as a service.

(1) To begin with, download and install latest SVN binaries you can find here. (2) Now right click on My Computer and choose Properties. Then, in the Advanced tab, click on the Environmental Variables button. A new window will pop up. In System Variables add a new variable called SVN_EDITOR with “C:\Windows\notepad.exe” as value. (3) Create a folder somewhere on your hard disk to hold code repository (example: F:\SVNRepository). (4) Open a command shell and type svnadmin create “F:\SVNRepository”. (5) In the F:\SVNRepository\conf folder, edit svnserve.conf and uncomment (delete the starting # character) the lines containing anon-access = read, auth-access = write and password-db = passwd. Save and close this file, then (6) edit passwd file. To add an user with write privileges to our repository, simply add a line to this file under [users] section, using the format username = password, so foo = bar creates user foo with password bar. (7) In the command shell type the following command to create the SVN service:

sc create svn.local binpath= “\”%ProgramFiles%\subversion\bin\svnserve.exe\” –service –root F:\SVNRepository” displayname= “Subversion Repository” depend= Tcpip

Please do not remove spacings since they are mandatory. (8) Open Control Panel, then select Administrative Tools and execute Services application. Look for the “Subversion Repository” service and run it. (9) To create a new project inside the repository, issue the svn create svn://localhost/myproject command. Feel free to write a comment in the newly opened notepad window and then close it. You will be asked for your password… et voilà 🙂

You can now use your favorite SVN client to do your first checkout, which will replicate SVN structure on your local project folder. I think that using TortoiseSVN will save you a lot of time 😉

References – Running SVN as a Windows Service
Vertigo Software – Setting up a Windows SVN server