Installing Subversion And Configuring Access Through Different Protocols On Debian Squeeze

Want to support HowtoForge? Become a subscriber!
 
Submitted by falko (Contact Author) (Forums) on Sun, 2011-07-31 18:41. :: Debian

Installing Subversion And Configuring Access Through Different Protocols On Debian Squeeze

Version 1.0
Author: Falko Timme <ft [at] falkotimme [dot] com>
Follow me on Twitter
Last edited 07/15/2011

Subversion (svn) is an open-source version control system (VCS), used in the development of many software projects. This tutorial shows how to install Subversion on Debian Squeeze and how to configure it to allow access to a repository through different protocols: file://, http://, https://, svn://, and svn+ssh://.

I do not issue any guarantee that this will work for you!

 

1 Preliminary Note

This tutorial concentrates on Subversion installation and configuration, not on its usage. You can find a list of usefull svn commands here: http://wiki.greenstone.org/wiki/index.php/Useful_SVN_Commands. The complete svn documentation is here: http://svnbook.red-bean.com/en/1.5/index.html

The Debian Squeeze system that I use here has the IP address 192.168.0.100 which I will use in the various svn commands throughout this tutorial. Make sure you replace it with your own server's IP/hostname.

 

2 Installing Subversion

Subversion can be installed as follows:

apt-get install subversion

Next we create a directory that will hold our repository/repositories - I use /var/lib/svn, but you can use another directory, if you like.

mkdir -p /var/lib/svn

I want to create a repository for my software project called myproject inside the /var/lib/svn directory - this can be done as follows:

svnadmin create /var/lib/svn/myproject

Of course, the repository is empty until we import our project into it.

There are several ways or protocols that can be used to access svn:

  • file:// - Through this protocol you get direct repository access. Works only on the same system (local disk), not over the network. Works out of the box.
  • http:// - It is possible to use WebDAV on a Subversion-aware Apache2 server to access a repository. Works over the network (port 80).
  • https:// - Same as http://, but over a secure SSL connection (port 443).
  • svn:// - Access to a repository is done through an svnserve server. Works over the network (port 3690).
  • svn+ssh:// - Same as svn://, but through an SSH tunnel (port 22).

 

3 Using The file:// Protocol

The file:// protocol works out of the box (it doesn't require any server process), but only locally, not over the network.

We can use it to import our software project (I have stored it in /home/falko/myproject) into our /var/lib/svn/myproject repository:

svn import /home/falko/myproject file://localhost/var/lib/svn/myproject

Checkouts can be done as follows:

svn co file://localhost/var/lib/svn/myproject /home/falko/somedir

 

4 Using The http:// Protocol

For the http:// protocol, we need to configure WebDAV on an Apache2 server. Therefore we install Apache2 and the Apache2 SVN module now:

apt-get install apache2 libapache2-svn

Now we configure the Apache2 SVN module by editing the file /etc/apache2/mods-available/dav_svn.conf:

vi /etc/apache2/mods-available/dav_svn.conf

There's a configuration already in the file, but it is commented out. You can leave it commented out, but at the end of the file, please add the following lines:

[...]
 <Location /svn>
  DAV svn
  SVNParentPath /var/lib/svn
  AuthType Basic
  AuthName "Subversion Repository"
  AuthUserFile /etc/apache2/dav_svn.passwd
  <LimitExcept GET PROPFIND OPTIONS REPORT>
    Require valid-user
  </LimitExcept>
 </Location>

Restart Apache:

/etc/init.d/apache2 restart

Because we will read and write to our repositories as the Apache user (www-data) and group (www-data) from now on, we must change the owner and group of /var/lib/svn and its subdiretories to the Apache user and group now:

chown -R www-data:www-data /var/lib/svn

Please note: If you decide to use http:// or https:// to access SVN, do not use any of the other protocols anymore to write to SVN because the ownerships of the changed files will not match the Apache user/group if you do not use http:// or https://!

Now we must create the password file /etc/apache2/dav_svn.passwd that contains all users that will have access to SVN (I will use the users falko and till here).

htpasswd -c /etc/apache2/dav_svn.passwd falko

Please note: Use the -c switch only if you create the /etc/apache2/dav_svn.passwd file for the first time. If you want to add another user, please leave it out (otherwise the file will be created from scratch again which means you lose all users that are already in the file):

htpasswd /etc/apache2/dav_svn.passwd till

You can now do a checkout as follows using the http:// protocol (please make sure you use the correct username):

svn co --username falko http://192.168.0.100/svn/myproject /home/falko/somedir


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.