Subversion via Apache+Webdav

This is how to set up the very minimum subversion server accessible by apache using plain authentication. No ssh, no ssl, no database authentication.

Related Reading

Install Packages

apt-get install subversion libapache2-svn

The install should automatically enable the module, but just to check:

a2enmod dav_svn

Create Repository

Using /svn for the path makes ssh access have a short path, rather than /var/lib/svn.

mkdir /svn
svnadmin create /svn/myproject
groupadd subversion
chown -R www-data:subversion /svn
chmod -R 770 /svn

Configure Apache

Create an apache configuration:

codetitle. /etc/subversion/apache.conf

<Location /svn>
  DAV svn
  SVNParentPath /svn
  SVNAutoVersioning ON

  # authentication
  AuthType      Basic
  AuthName      "Subversion Repository"
  AuthUserFile  /etc/subversion/auth/users
# AuthGroupFile /etc/subversion/auth/groups
</Location>

<LocationMatch "/svn/.+">
  Require valid-user
</LocationMatch>

Create a basic users file:

mkdir /etc/subversion/auth
htpasswd -c /etc/subversion/auth/users user1
htpasswd /etc/subversion/auth/users user2
htpasswd /etc/subversion/auth/users user3

Make sure to include /etc/subversion/apache.conf somewhere. For example:

<VirtualHost *:80>
  ServerName myserver.taz
  DocumentRoot /var/www/
  Include /etc/subversion/apache.conf
</VirtualHost>

Then restart apache.

Checking out the repository

Test to see if apache is set up right by browsing to http://myserver.taz/svn/myproject/. Login using one of the users stored in /etc/subversion/auth/users. If you see something that says:

Revision 0: /
Powered by Subversion version 1.4.4.

Then you should be good to go.

Check out the repo from your local machine:

cd ~
mkdir development
cd development
svn co http://myserver.taz/svn/myproject --username user1

Subversion Locally or Via SSH

Install Packages

apt-get install subversion

Create Repository

Using /svn for the path makes ssh access have a short path, rather than /var/lib/svn.

mkdir /svn
svnadmin create /svn/myproject
useradd subversion
chown -R subversion:subversion /svn
chmod -R 770 /svn

Add users to subversion group

Add a single user to group subversion:

# usermod -a -G subversion <username>

Alternately, you can edit the /etc/group file with this command:

# vigr

Checking out the repository

locally

% svn co file:///svn/myproject

via ssh

% svn co svn+ssh://username@hostname.taz/svn/myproject