Introduction

If you want to use Subversion, the successor of CVS, you first need to install Apache 2.

Installation

Here are the packages to install:

1
aptitude install subversion libapache2-svn subversion-tools

Configuration of SVN

Configuration of the module

Edit the “dav_svn” module:

1
vi /etc/apache2/mods-enabled/dav_svn.conf

Then adapt this configuration for your needs (/etc/apache2/mods-enabled/dav_svn.conf):

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 <Location /svn>
      #When the client accesses /svn the URL will be handled
      #by the directives here, thus by subversion 

      #Loading the subversion module 
      DAV svn
      # Path to your repository
      SVNPath ''/usr/local/svn
      # Path if you have multiple repositories
      SVNParentPath ''/usr/local/svn

      #Here we request authentication with password
      #use htpasswd2 to create the file
      AuthType Basic
      AuthName ''"Subversion Repository"
      AuthUserFile ''/etc/apache2/dav_svn.passwd

      #Here we only request authentication for writing
      #operations on the repository.
      <LimitExcept GET PROPFIND OPTIONS REPORT>
          Require valid-user
      </LimitExcept>
 </Location>

Apache Configuration

Add this to your “VirtualHost” in Apache configuration (/etc/apache2/site-enabled/default):

1
2
3
4
5
6
 <Directory /usr/local/svn>
     Options Indexes FollowSymLinks MultiViews
     AllowOverride None
     Order allow,deny
     allow from all
 </Directory>

Access Definition

Next, we will create a file containing users authorized to connect:

1
htpasswd -c /etc/apache2/dav_svn.passwd $USER

Setting up the repository

  • Creating a repo (repository):
1
svnadmin create /usr/local/svn/project
  • Importing a project:
1
svn import /home/$USER/project file:///usr/local/svn/project -m "initial import"

If everything went well, you should see this:

Committed revision 1.
  • Verification:
1
svn ls file:///usr/local/svn/project

Starting the daemon

To start the daemon:

1
svnserve -d -r /usr/local/svn/project --listen-port=3690

Set a listening port. 3690 is the default SVN port.

  • Log status:
1
svn log svn://localhost:3690

Usage

A repository within another repository

If, for example, you want to have a repository, then a folder inside it pointing to another repository, it’s possible by going to the folder that will contain the other repositories, then running this command:

1
svn propedit svn:externals .

Then, enter the name of the folder you want and the SVN address:

lib svn://svnsrv/trunk/library
  • lib: the folder containing this SVN repository
  • svn://: the SVN address

Here’s another example:

Nagios         http://svn/admin/Production/Nagios

You can then save this configuration to make it permanent by doing a commit.

References

Setting up an SVN repo
Apache Subversion Documentation
SVN and auto updatable working copy Documentation
Subversion and Trac as Virtual-Hosts documentation

Last updated 06 Jul 2012, 14:40 CEST. history