Install Version Control using Subversion on Linux

Subversion is a Free/Open-source Version Control System (VCS). That is, Subversion manages files and directories, and the changes made to them, over time. This allows you to recover older versions of your data or examine the history of how your data changed. It can operate across networks, which allows it to be used by people on different computers.

In this tutorial, we aim at installing Subversion on a Linux Ubuntu system and configuring it to run across a network using an Apache Web Server configuration.

To install the Subversion package on Linux Ubuntu:

sudo apt-get install subversion

To configure a folder as your repository for Subversion files, you can create it under the /var/ folder:

sudo mkdir /var/svn

At this point, there is different ways to configure Subversion, depending on the way your repository will be accessed:

  • Local: The access to your repository is done using the syntax file:/Folder/Project/, where Folder is /var/svn here.
  • Server: In this case, the access to your repository is achieved with either svn://MyServer/Project/ or http://MyServer/Project/, where MyServeris the name of your server, and which we will be defined later on.

In the first case, the SVN users are locally created for the task, and only users working on the actual workstation can have access to the repository. In the second case, a list of users will be created for the dav_svn module, and the repository can be accessed over a network using an Apache server configuation.

In this tutorial, we will adopt the second configuration. The repository will be named Project, which will be created under the folder /var/svn, and will be accessed using the URL http://MyServer/Project/.

In order to install an SVN using the Apache Web Server, we have to first install the apache2 libapache2-svn package:

sudo apt-get install apache2 libapache2-svn

We have also to activate the dav_svn module, which is deactivated by default:

sudo a2enmod dav_svn

In order to change the default name of the Apache server, edit the /etc/hosts file:

sudo vi /etc/hosts

Edit the first line of the file, by adding MyServer to its end, as to get:

127.0.0.1 localhost MyServer

Open the /etc/apache2/mods-enabled/dav_svn.conf file, and edit it as to get the following lines activated:

<Location /Project>
DAV svn
SVNParentPath /var/svn/Project

After SVNParentPath, you can add the following line sothat http://MyServer/svn displays the list of all the existing SVN projects:

SVNListParentPath On

Close the Location environment by activating:

</Location>

At this point, the Apache server is configured, and should be restarted:

sudo /etc/init.d/apache2 restart

Create the deposite Project and give access privilégies only to the Apache server:

sudo svnadmin create /var/svn/Projet
sudo chown -R www-data:www-data /var/svn/Projet

Note that you can ue the previous same commands to create as many deposites as needed…

Before continuing, be sure that your Apache server is working, by typing http://MyServer/ on your browser. It should displays “MyServer Works“!

Back to the /etc/apache2/mods-enabled/dav_svn.conf file for configuring the authentification. Modify the existing lines so as to obtain the following:

AuthType Basic
AuthName "SVNDeposit"
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user

Using the htpasswd, create the /etc/apache2/dav_svn.passwd file:

sudo htpasswd -cs /etc/apache2/dav_svn.passwd User_1

User_1 is the name of the authorized user.

And for creating further users:

sudo htpasswd -s /etc/apache2/dav_svn.passwd User_2

This file should belongs to the Apache server’s user:

sudo chown www-data:www-data /etc/apache2/dav_svn.passwd

Restart the Apache server again:

sudo /etc/init.d/apache2 restart

And we are done! By now, your deposit is now accessible under the URL http://MYServer/svn/Project, and authentification is asked before accessing the deposit!

This procedure have been successfully configuraed on a Linux Ubuntu 12.04 LTS system.

Credit: Detailed procedure and more options on the Ubuntu Documentation Community‘s website.

Tagged , , , , , ,

Leave a comment