Simple guide to install SVN on Linux : Apache Subversion

Apache Subversion or as it is normally called, SVN, is a Software versioning & revision control system. It has been around since year 2000 & still is being used by organizations & open source communities worldwide. In fact many big open source projects like ruby, python, apache, source forge etc have been using SVN.

It 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. But like any other software its not perfect & has some limitations, like when it comes to speed it tends to be bit slower than other & there is a known bug relating to renaming files and folders.

Though in latest times, SVN has lost its shine to GIT and other version control system but none the less many still prefer to use it. In this tutorial, we will learn to install SVN on Linux systems (Ubuntu & CentOS).

(Recommended Read: How to install GIT on Linux (Ubuntu & CentOS) )

(Also Read: Install Gitlab on Ubuntu & CentOS : A complete guide )


Install SVN on Linux


Step 1- Install SVN

Firstly, we will start by installing SVN on our system. To do that, execute the following command from your terminal,

For CentOS,

$ sudo yum update
$ sudo yum install subversion

For Ubuntu,

$ sudo apt-get update
$ sudo apt-get install subversion

Once we have installed SVN, next step is to create a directory for SVN & also modifying its permissions & ownership.

Step 2 – Creating SVN directory

We will be using ‘/var/www/svn’ as our SVN directory. Create the directory with the following command,

$ sudo mkdir /var/www/svn

Now create a new folder inside the SVN directory for our first repository,

$ cd /var/www/svn

Now we will create our first SVN repo inside the /var/www/svn folder with the following command,

$ sudo svnadmin /var/www/svn/first-repo

Next we will change the svn folder ownership to user and group for apache server,

$ sudo chown -R apache:apache /var/www/svn

For Ubuntu, apache user is ‘www-data’, so the command to change ownership of the svn folder will be,

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

Also, make sure that it has 755 permissions (usually it’s the default permissions),

$ sudo chmod -R 755 /var/www/svn

Step 3 – Install Apache & mod_dav_svn

Apache is a webserver & module mod_dav_svn is used to allow access to repository using HTTP i.e. apache webserver. Install both the packages with the following command,

For CentOS,

$ sudo yum install httpd mod_dav_svn

For Ubuntu

For Ubuntu, we need some other packages as well. Install them using the following command,

$ sudo apt-get install apache2 libapache2-mod-svn libapache2-svn

Step 4– Enabling modules & configuring Apache server

Now we will enable the module mod_dav_svn & also will make the configuration changes for enabling SVN repository on webserver. We will be configuring SVN with basic authentication, so that our repository in not open to all & can only be accesses by valid users.

Make the changes as follows

For CentOS,

$ sudo vi /etc/httpd/conf.modules.d/10-subversion.conf

& make the following entries into the file,

LoadModule authz_svn_module modules/mod_authz_svn.so
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule dontdothat_module modules/mod_dontdothat.so

<Location /svn>
DAV svn
SVNParentPath /var/www/svn
AuthType Basic
AuthName “SVN Repo”
AuthUserFile /etc/svnusers
Require valid-user
</Location>

Now save the file & exit. Next step is to restart the apache service to implement the changes.

$ sudo systemctl restart httpd

For Ubuntu

To enable the module in apache, we need not make any file entries rather we need to execute the following command from our terminal,

$ sudo a2enmod dav
$ sudo a2enmod dav_svn

Next open the Apache svn config file, which for Ubuntu is located at following location “/etc/apache2/mods-enabled/dav_svn.conf” ,

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

& make the following entry to the file,

<Location /svn>
DAV svn
SVNParentPath /var/www/svn
AuthType Basic
AuthName “SVN Repo”
AuthUserFile /etc/svnusers
Require valid-user
</Location>

Save the file by pressing ‘CTRL+X’ & restart the apache service to implement the changes made,

$ sudo systemctl restart apache2

Step 5 – Creating SVN user accounts

We will now create couple of users to access the SVN server via http. Open terminal & run the following command to create users,

$ sudo htpasswd -cm /etc/svnusers svn1
$ sudo htpasswd -m /etc/svnusers svn2

We will be prompted to enter the password, provide one & than re-enter it to confirm. Also restart the Apache service, once you have added the users.

Step 6 – Accessing the SVN repository

We have now configured our first SVN repository & are now ready to access it. To access the SVN repository, open your web browser & enter the following URL,

http://127.0.0.1/svn/first-repo

This should open the SVN authentication page & upon successful authentication, we can access our SVN repo. Replace the IP address with the yours accessing it on remote systems.

That’s it guys, we now end our tutorial on how to install SVN on Linux machines. Please feel free to send in any queries/suggestions 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:

Linux TechLab is thankful for your continued support.

Shusain

Passionate about Linux & open source. Loves to learn, read & write about Linux as well as new technologies.

You may also like...

1 Response

  1. funny onesies for adults says:

    Whats up very nice website!! Guy .. Excellent .. Wonderful .. I’ll bookmark your website and take the feeds additionally? I’m satisfied to find a lot of useful info right here in the post, we’d like develop more techniques in this regard, thank you for sharing. . . . . .

Leave a Reply

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