SVN Server Configuration in Windows

Sunday, January 9, 2011

Setup is actually pretty straightforward. To use SVN in standalone mode (without Apache), just download the installer (I used svn-1.6.15-setup.exe).

Installing Subversion
- Double-click on the installer and run through it. Shouldn't take too long. Once installed, add an environment variable for SVN_EDITOR. You can do this by right-click on my Computer > Properties. Go to advanced. Hit the Environmental Variables button. Just add another in there called SVN_EDITOR with a value of C:\windows\notepad.exe

Creating a Repository
- Now you need to create a repository. Go to the command prompt (Start > run > cmd). type "svnadmin create D:\Programming\MySVNRepos". (Change the path to whatever path you want to use.) The repos is basically a special directory that will hold your files as well as various subversion config options.

Modifying Security and Authentication Settings
- Next up, you need to modify the permissions and users. Navigate to the folder you just created. In my example, I used D:\Programming\MySVNRepos". In this directory, you will find a few folders. One folder will be called conf. Navigate to it and double-click on the svnserv.conf file. Opening it with notepad will be fine.

- The svnserv.conf file in a configuration file for the svnserv executible. For our purposes, just uncomment out the following lines:

anon-access = read
auth-access = write
password-db = passwd

- Save your changes. And double-click on the passwd file in the same directory. The file stores all usernames and passwords in the format:
$username = $password

- Make sure the [Users] line is uncommented and you can just add a new line for your username and password. For example, if you wanted your username to be josh and your password to be testing, just create a line like this:

josh = testing

- Save it and you're done configuring.

Serving Your Repos for the First Time
Now, you can test it out. Go to the command prompt again and type:
svnserve --daemon --root "D:\Programming\MySVNRepos"
Change the path to your specified path. Once this is done, the daemon should be listening and waiting for requests.

Creating your First Project folder
- Next, we can create a project folder in subversion. To do this, open up a new command prompt. We can't use the old one as our daemon will shutdown. Once you're in the new window, type the following:
svn mkdir svn://localhost/TestProject

- Once you type this in, notepad will appear (assuming you set the SVN_EDITOR variable at the very beginning). This is basically used for the log so you can just leave it be for our test example and close it out.

- After you close out notepad, subversion will ask for your username and password. However, keep in mind, it may also ask for your computer's Admin password. If it does, you can simply type in your computer's admin password. Once you hit return, you can then go ahead and type in your subversion username and then your subversion password. Your subversion username and password is exactly what you typed in the passwd file. (i.e. user: josh pass:testing)

- If you've successfully typed in your username and password, it should say Commited Revision 1. This is a good thing.

Finishing Up
- After that's completed, you're basically done. Your subversion repos has been setup. However, we have a few problems.
1. You probably don't want the command window up all the time when running your subversion daemon.
2. Accessing subversion via command prompt is ok, but it could be better.

Running svnserv as a Windows Service
If you're running XP (Win2k, Win2k3, or Vista), you can tell the process to run as a service. Stop your existing svnserv daemon by closing out of the existing command prompt window. Now, go to the command prompt (again). Type:

sc create svnrepos binpath= "\"C:\program files\subversion\bin\svnserve.exe\" --service --root \"D:\Programming\MySVNRepos" displayname= "Subversion Repository" depend= Tcpip start= auto

Ed. Note: The key/value pairs must be in the form key=_value where the underscore is representative of a space. Also, if you mess up here and the service is still installed, you will need to uninstall the service. You can do so by using sc delete svnrepos (or whatever service name you used). You will need to log off and back on for the service to be completely uninstalled. Also, the "Subversion Repository" is simply a label, you may also call this whatever you'd like.

This simply creates a new service in Windows. Of course, you will need to replace "D:\Programming\MySVNRepos" with the path to your repos that you created. Assuming that you install subversion in the default location, you should just have to run that. Now, just start it by typing:

net start svnrepos

You're done. If you want to change some service settings, such as turning on auto start, just go to Start > run. Type services.msc. Find the service with the Display Name set to "Subversion Repository", right-click on it and select Properties. You can change a few different things in there.

Download TortoiseSVN
Go to tortoisesvn.tigris.org and download TortoiseSVN. The tool is essentially a Windows shell extension that allows you to execute SVN commands from Windows Explorer. It's, honestly, the only subversion tool you really need if you're on a Windows computer. Once you install this, you can then view your repos via a tree view type situation.

For example, go to start > run and type:
svn://localhost

If your service/daemon is started, you should be able to expand the nodes to view your projects and files. You can also create new folders and do a plethora of different tasks in it as well. Also, if you go into Windows explorer, and right-click on any folder, you'll see a new TortoiseSVN submenu, with a few different options. You can then easily import an entire project folder into subversion with ease.

0 comments: