Install SVN on Ubuntu

Install SVN on Ubuntu

User Guide for installation and configuration of Subversion on Ubuntu systems, complete with basic authentication and web access.

To install subversion, open a terminal and type in the following command:

sudo apt-get install subversion


It will install the necessary modules: SubVersion and the SVN libraries for Apache2.
The SVN module should automatically be enabled on Apache after the installation but, if not, you can enable it by the command a2enmod as described below:

sudo a2enmod dav_svn Sudo a2enmod dav_svn


The next step is to create the repository for subversion, which can in example be /svn, although you can choose the path you want, based on your tastes and on the space available in your disk.

sudo svnadmin create /svn


Then we will have to modify the configuration file to the webdav/SVN module. In this case, we're using gedit editor, but you can use the one that you usually use.

sudo gedit /etc/apache2/mods-enabled/dav_svn.conf


The "Location" parameter in the configuration file indicate the directory where subversion is accessible, as in the following example:
http://www.mysite.com/svn

<Location /svn>


The "DAV" line should be uncommented to enable dav module (remove the pound before the line).

DAV svn


The "SVNPath" parameter should be equivalent to the location where you created the SVN repository using svnadmin command.

SVNPath /svn


The next section will let you activate authentication. This can only be considered a basic authentication, not very safe. The file that contains username / password associations will be saved at that location described in AuthUserFile parameter, which would be best left to the default value. Uncomment then the following 3 lines to activate the Basic Authentication.

AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.passwd


To create a user, with the permission of access to the repository, simply run the command:

sudo htpasswd -cm /etc/apache2/dav_svn.passwd username


The -c option should be used only for the creation of the first user, so that the file is created. After that you have to use only the -m option, which apply a MD5 encryption to the password, but avoids to recreate the file.

Example

sudo htpasswd -cm /etc/apache2/dav_svn.passwd icelab
New password:
Re-type new password:
Adding password for user icelab


Then make sure you set the permissions of the /svn directory to apache with the following command:

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


At the end of the installation process remember to restart Apache, using the command:

sudo /etc/init.d/apache2 restart


After apache rebooting, if you'll visit from your browser (i.e. Firefox) the http://www.mysite.com/svn address, you should see that the repository allows anonymous read-only access, but to run the commit changes will be required username and password.
If you want to require the login for read-only access, you have to insert the following line in the configuration file, under the AuthUserFile line:

Require valid-user


After that, restart apache and you have a working SVN server!

Notes

The installing procedure was tested on Ubuntu 7.10 and has been running at 100%. However, there may be found some differences depending on your system configuration.

tags svn install, install subversion, subversion ubuntu

Publication details

Category: Apache and Web Server

Published by: loryzz on date: 04.04.2008 11:59:28

Last edit by: loryzz on date: 20.06.2008 14:31:35

Statistics

Details  This article has been viewed 4.541 times.

Send to

add to digg add to reddit add to furl add to facebook add to delicious add to google add to stumbleupon add to technorati add to ask add to live

Ratings

  • Currently 0; ?>/ TOTALSTARS
  • 1
  • 2
  • 3
  • 4
  • 5

Comments

Details 2 user comments, 0 still waiting.

  1. Comment by: Jacques on date: 20.10.2008 20:36:24

    Thanks a stax - worked like a dream just had to add sudo apt-get install libapache2-svn in my case.

    Ciao

  2. Comment by: Ranjan Yengkhom on date: 20.11.2009 12:46:43

    I have followed the steps properly. My problem is with login authentication.

    Suppose I have sreated the following user:
    sudo htpasswd -cm /etc/apache2/dav_svn.passwd test

    When I open my svn as
    http://xxx.xxx.xxx.xx/svn
    I get the login page. then login with the user(test) and correct password. But I got the message

    You don't have permission to access /svn/testKRA on this server.

    Can u plz help me... what else setting I need to change

Leave a comment

All comments must be approved by site administrator.
Please write comments on topic. Spam will be never approved.


Confirmation code

Please take a look to image and insert character into the form field.