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 SVN 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.
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.
Creating users for SVN
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 SVN 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.
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