Tuesday, January 15, 2013

Setting up a SVN Server

Introduction

I've recently added some revision control to my Ubuntu virtual server. I added Subversion and Git support. Here I'm documenting the process I used to setup a Subversion server.

I'm following for the most part Ubuntu's SVN tutorial.

Server Setup

First things first, install the subversion package on the server.

sudo apt-get subversion

Next setup a svn repository using the svn admin. I'm using the /opt/svn/ folder to stage my repos.

I've also given control of the repo to the svn group, and modified the permissions to allow the svn group to modify

sudo mkdir -p /opt/svn/myrepo/
sudo svnadmin create /opt/svn/myrepo/
sudo chown -R root:svn /opt/svn/myrepo/
sudo chmod -R g+rws /opt/svn/myrepo/

Unfortunately, I don't think there's a svn module for NginX which means I can't use the http and https protocols. Luckily svn provides the svn+ssh protocols.

ssh://

This command runs the svnserve subversion server. However, this command will not start automatically by itself.

svnserve -d -r /opt/svn

I have the upstart script located at /etc/init/svnserve.conf.

# svnserve
#

description "Subversion server"

start on (local-filesystems and net-device-up IFACE=lo and started udev-finish)
stop on runlevel [06]

chdir /opt/svn

respawn

respawn limit 2 3600

exec /usr/bin/svnserve -d -r /opt/svn/

To run the upstart script:

sudo initctl start svnserve

To provide a basic authentication system, we can edit the svnserve.conf file under /opt/svn/myrep/conf/ to use the password-db file.

Then, to checkout this repo:

# Note: my virtual server IP is static at 10.0.0.2
# this checks out svn://10.0.0.2/myrepo/ to ./local_copy 
svn co svn://10.0.0.2/myrepo/ local_copy

ssh+svn://

The TortoiseSVN website has a great how-to guide for setting up svn+ssh and TortoiseSVN. I'll just link to it: TortoiseSVN - Securing Svnserve using SSH.

The one note I did have is that you don't need to use svnserve when using svn+ssh, but you do need to provide the full path.

# with svnserve rooted at /opt/svn/
# my putty configuration is named lemp, set to auto-use my username helloworld922
svn co svn+ssh://lemp/myrepo local_copy

# without svnserve
svn co svn+ssh://lemp/opt/svn/myrepo local_copy

Also, TortoiseSVN tries to make the connection tons of times. Unless you really like entering your passphrase a lot (or even worse, don't have one for your private key), I would recommend using the Pageant tool provided with PuTTY. TortoisePLink can take advantage of this out-of-the-box.

That's all for now, I'll go over setting up the Git server later.

No comments :

Post a Comment