Tuesday, December 4, 2007

Setting Up Subversion Server on Windows

Getting subversion working on windows isn't that bad of a task. I've been using it to track Visual Studio projects here at work. While it isn't too hard to do, it can be confusing the first time around. I also end up forgettting commands so putting it in one spot is probably a good idea. So, here is my attempt at making a tutorial, as much for me later as for you now.


Things You'll Need



  1. Subversion Windows Binary Package. The version I'm installing is 1.4.3. http://subversion.tigris.org/project_packages.html

  2. A way to manage your repository. I use tortoisesvn on windows. This is the client piece to the equation. http://tortoisesvn.net/



Create a Repository


Install the Subversion binary package. This is extremely straight forward and only requires clicking next and continue until it's complete. It will install to documents and settings\subversion.

Once Subversion is installed a location for the repository needs to be created. I normally pick some place that gets backed up by a regular server backup. It my case it is going to be F:\Subversion. Just create an empty folder to hold our projects.

This is a matter of preference, but I like to set up my projects under the main root folder and manage each of them seperately. This means I need to create logins and passwords under each repo, but I like how it is split up. An example is that my projects will be f:\Subversion\MyProject1. So, create a folder for this project and we'll get to setting up the repository.

To create a project skeleton, I used the command svnadmin create "F:\Subversion\MyProject1". This will create a bunch of folders and files in the MyProject1 Directory.

Set Security

Now the security for the repository needs to be set. It seems like there are a lot of options to configure security, but I'm going to use the default file based security. To set this up, I opened svnserve.conf in the conf directory of the project and uncommented anon-access = read and auth-access = write. I also changed anon-access from read to none because I don't want to allow anonymous access to my repository. It is also necessary to uncomment password-db=passwd.

Save the file and open up passwd file and put in the username and password that you will use to access the repository.

Test The Repository

Now test the repository by running the command svnserve --daemon --root "F:\Subversion" from the terminal. This runs the subversion daemon and serves up all of the projects under F:\Subversion. Using tortoiseSVN, connect to svn://hostname/MyProject1. This can be done by right clicking on a folder and going to the Repo browser. If the connection works, you should be ready to run Subversion as a service and then start adding content to your repository.


Registering Subversion as a Service


Now that we have subversion set up, lets register it as a service on windows. There are a few ways of doing this, but I used the sc command that is packaged with Subversion. I opened a command prompt and typed this in to create a service C:\>sc create svnserve binpath= "C:\Program Files\Subversion\bin\svnserve.exe --service --root F:\Subversion" displayname= "Subversion" depend= tcpip start= auto obj= "NT AUTHORITY\LocalService". This creates a Subversion service that is serving F:\Subversion and starts automatically. It also runs using the "NT Authority\LocalService" account which is recommended. You may need to start the service by going into the windows services and starting the Subversion Server.

Adding Files to the Repository

To add files to the repository, right click on the folder that contains the source and click import. Then give it the svn://hostname/MyProject1. This will upload your files into the repository and set the revision to 1.

Getting to work

You can now right click on any folder with Tortoise and checkout the files to that folder to start working on them.

Helpful Links

I used the following links to help me install Subversion. Thanks to the people that wrote them and hopefully they are helpful to you as well.

Running Subversion as a service.

http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-serversetup-svnserve.html

Installing and Configuring the Server

http://www.excastle.com/blog/archive/2005/05/31/1048.aspx

No comments: