Setting up a Subversion server on Windows Server 2003

If you need a program for unpacking zip files then install 7-zip.

Get the Subversion 1.4.5 setup and run it to install Subversion.

Installing svnserve as a service

The simplest way to set up a server on Windows is to use svnserv which can be installed as a Windows service.

Run these commands in order to get the service up and running:

mkdir c:\svn
svnadmin create c:\svn\repos

Start the service:

sc create svn binpath= "\"C:\program files\Subversion\bin\svnserve.exe\" --service -r C:\svn" displayname= "Subversion Server" depend= Tcpip start= auto
net start svn

Note: There really are spaces after the = signs.

Check that it worked by checking out the repository:

svn checkout svn://localhost/repos

Adding security

Edit C:\svn\repos\conf\svnserve.conf, uncomment these lines and change anon-access to none:

anon-access = none
auth-access = write
password-db = passwd
realm = My Subversion Repository

Now edit C:\svn\repos\conf\passwd and add a user name and password to the users section:

[users]
martin = dgjan08

Delete your first checkout and try to check out the repository again, this time you will have to supply a user name and a password.

Using WebDAV via Apache 2.2

Get and install XAMPP, install Apache and MySQL as a service. Unblock ports as needed when the installation is finishing up.

As we are installing Apache 2.2 so we need builds of the Subversion Apache modules which are compatible with Apache 2.2 which are available here.

XAMPP has a prebuilt mod_dav_svn and mod_authz_svn - they don't work, replace them with the Apache 2.2 built ones which you have just downloaded, the zip file contains a complete build of Subversion but we only need the two Apache module files. The files to replace are mod_dav_svn and mod_authz_svn in c:\xampp\apache\modules.

Edit C:\xampp\apache\conf\httpd.conf and add:

Include conf/extra/httpd-subversion.conf

Put this in that file:

LoadModule authz_svn_module modules/mod_authz_svn.so
LoadModule dav_svn_module modules/mod_dav_svn.so

<Location /svn/repos>
  DAV svn
  SVNPath c:/svn/repos
</Location>

Stop and start the Apache service, either using the command line or the XAMPP Control Panel Application. Fire up a web browser and go to http://localhost/svn/repos.

Adding Security

In httpd-subversion.conf, add this to the Location directive:

  AuthType Basic
  AuthName "Subversion Repository"
  AuthUserFile c:/svn/passwords
  Require valid-user

Now create a password file and add a user, note: xamp htpasswd doesn't like drive letters.

C:\svn>c:\xampp\apache\bin\htpasswd -cb \svn\passwords martin dgjan08
Automatically using MD5 format.
Adding password for user martin

Then restart Apache again. You will now need to use the user name and password to access your repository.

Using SSH

This requires the installation of cygwin, make sure that the OpenSSH server is selected in the Net section.

Now start the Cygwin Bash shell and run this command:

/usr/bin/ssh-host-config

Choose these options:

  • Yes to privilege separation and create the required user.
  • Install as a service: yes
  • create a sshd_server account: yes
  • Enter a password
  • Enter on the env var question.

Then start the ssh service:

net start sshd

Add a user account (in computer management), set a password and then run these commands:

mkpasswd -l > /etc/passwd
mkgroup -l > /etc/group

Now log out and then log in as the new user. As the new user start the Cygwin shell and run:

/usr/bin/ssh-user-config

Say yes to everything and enter passphrases as required. You are now set up. Test it by running this command (accept the RSA fingerprint and enter your passphrase):

svn ls svn+ssh://localhost/svn/repos

Alternatively you can generate your key pair and set up PuTTY and TortoiseSVN as described in setting up a server on Ubuntu Gutsy Gibbon. Using the Cygwin shell they need to go in a .ssh folder in your home directory. The easiest way to ensure success is to let the ssh-user-config script generate a key and then overwrite it with a PuTTY generated one.

Sat, 2007-12-15 21:16
( categories: )