How to install and configure SVN on Ubuntu

How to install and configure SVN on Ubuntu

Subversion – another name we known as SVN, is an open source version control system. SVN is a really easy to use Revision control/version control/source control and store changes of your project files such as coding and documentation.
In this tutorial we will discuss how to install subversion on Ubuntu 14.04.
Follow the below mentioned commands to install SVN packages

sudo apt-get install subversion subversion-tools libapache2-svn

Create a new directory where you would like to store svn files

mkdir /svn

Permission modification for the repository

sudo chown -R www-data:www-data /svn/

Create a new repository with the command below

sudo svnadmin create /svn/REPOSITORY_NAME

You will have to change ownership each time you create a repo

sudo chown -R www-data:www-data /svn/REPOSITORY_NAME

We will confirm that apache2-utils is installed which we would be needing for command below (htpasswd)

sudo apt-get install apache2-utils

To store user authentication details, create a file as shown below (/etc/subversion/users_passwd)

sudo htpasswd -c /etc/subversion/users_passwd USERNAME

Here users_passwd is the filename and USERNAME is the username for accessing repository.
For additional users have to omit -c onwards.

sudo htpasswd /etc/subversion/users_passwd USERNAME

Create /etc/apache2/sites-available/svn.conf file and add the below lines.

<location /repos>
 DAV svn
 # SVN path
SVNParentPath /svn/
SVNListParentPath On
 AuthType Basic
 AuthName "SVN Authorization"
 #password file path
 AuthUserFile /etc/subversion/users_passwd
 AuthzSVNAccessFile /etc/subversion/users_repo_authz
 # SVNPath /svn/
 Require valid-user
 </location>

Now we will activate the virtual host configuration

sudo a2ensite svn.conf
service apache2 reload

Restart apache service now.

sudo /etc/init.d/apache2 restart

Create file /etc/subversion/users_repo_authz

[REPOSITORY_NAME:/]
USERNAME = rw

REPOSITORY_NAME is the name of the repo and after colon you can also restrict user to repo directory also by adding following line

[REPOSITORY_NAME:/beta_code/]
USERNAME2 = rw

We will restart apache to take effect of users_repo_authz file changes. Otherwise you will get permisison denied message.

sudo /etc/init.d/apache2 restart

Now you have successfully installed and configured SVN server on ubuntu 14.04.
We suggest to use svn clients such as Tortoisesvn for windows and Rapidsvn for Ubuntu. For a quick testing, Open any folder right click and Tortoisesvn checkout will appear. You can place url   http://HOSTNAME/repos/REPO_NAME in the box and after successful authentication you can checkout, update, commit code in that folder.
 

Share this post

Leave a Reply

Your email address will not be published. Required fields are marked *