Setting Up A Dedicated SVN Server

By | December 10, 2006

All software developers have to deal with it. Version control software. Today I decided to play a bit with installing my own dedicated SVN (subversion) server. This, hopefully brief, step plan will help you do the same :).

Downloading all needed software
Before you can continue with the tutorial you will have to get the following things:

  • A ‘virtual’ computer to install you dedicated SVN server on,
    I used VMWare to emulate a server, but you could also use an old computer that you have as a spare.
  • Download Debian from http://www.debian.org/devel/debian-installer/,
    The reason for picking debian is easy. It’s supposed to be a stable and powerful Linux OS. (You can pick the netinst CD image)

That’s all you will need. But be aware that we will be downloading various other packages (software applications) later on. So make sure you have your network prepared.

Installing Debian
Since I’m a complete newbie with Linux I just accepted all of the default settings. Which is fine for most people, but don’t do this for a company SVN server. It’s not really secure ;).

Setting up subversion on your server
You will need to login as root on the just installed Debian server. If you are set then it’s time to download some additional software. Just run the following commands:

apt-get update
apt-get install subversion
apt-get install libapache2-svn

If Debian starts asking you questions just answer them with ‘Y’, mostly it will confirm if you want to install the packages. After this step you’ve just installed SVN on your server. Easy isn’t it :D.

Setting up the svn root
The next step is creating the svn root, which basically is the location were all your files will be stored. What I usually do is create a directory in the /home directory. But it’s your server so create it wherever you want to.

mkdir /home/svnroot
svnadmin create –fs-type fsfs /home/svnroot/project_worms
svnadmin create –fs-type fsfs /home/svnroot/project_cats

As you see I created two different svn root’s. Most people love to create one for each project or each department. But do whatever you like.

Creating users for subversion
To be able to use subversion you need to give people access to it. So the next thing we will be doing is setting up some user accounts and a user group for subversion. You can do this by executing the following commands.

groupadd subversion
adduser bob -g subversion -p bobpass
adduser dylan -g subversion -p dylanpass

The first commando creates the group we will be using. The next two commando’s create a user. By using ‘-g’ you can set the group the user belongs to. With ‘-p’ you can set the password.

Now you can continue with setting up secure access to you SVN, but as I said before I’m just installing a private server so I don’t need it.

Confirming subversion is working
To make sure everything is working you can execute the following commando’s. The first will verify SVN is working the other two that the integration with Apache is working properly.

svnlook tree /home/svnroot/project_cats
a2enmod dav
a2enmod dav_svn

Preparing password protected access
In this step we will set up the protected access through Apache. This is done so we can access the svn root on other computers, which is the point :). Run the following commands to create a password file that we use to limit access.

htpasswd2 -c /etc/apache2/dav_svn.passwd bob
htpasswd2 /etc/apache2/dav_svn.passwd dylan

You can add as many users as you want, but keep it maintainable. The next step is creating a file to set up the access through Apache. But before I give you that let’s explain some basics of vi, which is the text editor you’ll be using.

To browse through a file you can use the arrow keys on you keyboard. To start editing you can either press i or a both enable the edit mode. The first is insert and will push the text after the cursor back. The latter is append and will make the typed text appear after the selected text. To leave edit mode press esc. To remove an entire line press dd. For a complete list view http://www.chem.brown.edu/instructions/vi.html

Now open the file /etc/apache2/mods-available/dav_svn.conf and put the following text in it.

<Location /svn/cats>
    DAV svn
    SVNPath /home/svnroot/project_cats
    AuthType Basic
    AuthName “Subversion Authentication – Project Cats”
    AuthUserFile /etc/apache2/dav_svn.passwd
    Require valid-user
</Location>

What these few lines do is simple. It creates an alias on http://localhost/svn/cats and maps it to the previously created svn root. The AuthType, AuthUserFile combination enables simple password protection for the folder.

Warning: You should create just as many entries in this file as you have svn roots, which you created a few steps earlier.

Now you need to complete the installation by restarting Apache. This will apply all changes we’ve just made. Just run the following command:

     /etc/init.d/apache2 restart

Optional: Setting a fixed IP
The last step of this tutorial is optional. Since this is a server you may want to set it up with a static IP address instead of a DHCP one. To do that edit the file /etc/network/interfaces.

It should have at least one entry named iface eth0 inet dhcp. You need to change that to the following:

iface eth0 inet static
    address 192.168.12.2
    netmask 255.255.255.0
    gateway 192.168.12.1

Now if you’re not familier with the network your SVN server will be in ask the network administrator what the settings should be. But generally speaking you can use the ones I just gave, except for the gateway. Set this to your routers IP address.

The next article I will post will be on how to install Trac, which will help you manage your SVN projects. But that’s for a later time.

2 thoughts on “Setting Up A Dedicated SVN Server

  1. Pingback: Narnio » Setting Up SVN Under Windows

Leave a Reply