SVN is a software versioning & revision control system, that has been around for a while now but is still being used by many. Though in recent years, Git & Git related applications are gaining all the popularity but that does not mean SVN is gone or is not useful anymore.

In this tutorial, we will learn to install SVN on Ubuntu & will also configure it with a test repository. SVN is easy to setup & administer, also provide fast & flexible update commits. There are number of clients available to use for various operating systems for using SVN.

Recommended Read : Easiest guide to migrate SVN to GIT: Convert all SVN repositories

Also Read : Complete “Beginners to PRO” guide for GIT commands

So let’s start with the pre-requisites first,

Pre-Requisites

We need to have apache installed on our system as we will use http to access all the SVN repositories. To install Apache on Ubuntu, use the following command,

$ sudo apt-get install apache2

Now we will move on to part where we install SVN on Ubuntu.

Install SVN on Ubuntu

SVN packages are being maintained by Ubuntu also & we need not install any additional repos to install SVN on Ubuntu. We can install is simply with the following commands,

$ apt-get install subversion libapache2-svn

Client and server are part of the subversion package, mod_dav_svn is in the separate libapache2-svn package. mod_dav_svn is used to expose SVN repositories to clients & also acts as a repository browser. We also need to install some other packages that have some other modules that we would need,

$ sudo apt-get install libapache2-svn libsvn-dev

Now after the installation of these packages, we will enable the required apache modules i.e. ‘dav’ , ‘dav_svn’,

$ sudo a2enmod dav
$ sudo a2enmod dav_svn

& lastly restart the Apache service to implement the changes,

$ sudo systemctl restart apache2

 

Configuration

Now we will create a directory where we will store all the SVN repositories. For this tutorial, we will use ‘/var/www/svn’ as our main SVN home directory. Create it with the following command,

$ mkdir /var/www/svn

Now we assign the proper permissions $ ownership to the folder,

$ chmod -R 755 /var/www/svn
$ chown -R www-data:www-data /var/www/svn

Next, we will create our first repository inside the SVN home directory, using the following command,

$ svnadmin create /var/www/svn/test-repo

Our directories are now ready, we only need to configure the apache server. Open the following file,

$ sudo nano /etc/apache2/mods-enabled/dav_svn.conf

& make the following changes to the file,

Alias /svn /var/www/svn
<Location /svn>

DAV svn
SVNParentPath /var/www/svn

AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/svn.passwd
Require valid-user

</Location>

Now save the file & exit. Next step is to create some users that have permission to access the SVN repository. To users, run the following command from terminal,

$ sudo htpasswd -cm /etc/apache2/svn.passwd dan

$ sudo htpasswd -cm /etc/apache2/svn.passwd susan

With this command, we have created two users ‘dan’ & ‘susan’ that can access the SVN repositories. Now we need to restart the apache service to implement all the changes,

$ sudo systemctl restart apache2

 

Accessing SVN repository

Now to access the repository, open browser & enter your svn URL,

You will than be asked to enter the credentials. Upon successful authentication, we can access the data stored in the repository.

That’s it, this completes our tutorial on how to install SVN on Ubuntu. Please feel free to share any thoughts or queries using the comment box below.

If you think we have helped you or just want to support us, please consider these :-

Connect to us: Facebook | Twitter | Google Plus

Donate us some of your hard earned money: [paypal-donation]

Linux TechLab is thankful for your continued support.