Setup Subversion (SVN) Repositories on Debian/Ubuntu

Published on: Tue, Sep 23, 2014 at 10:54 pm EST
Debian Linux Guides Ubuntu

Install required packages

We are going run SVN under xinetd for low resource usages.

apt-get install xinetd subversion

Create svn user

adduser --system --home /var/svn --disabled-password --disabled-login --group svn

Create your first repository

svnadmin create /var/svn/repositories

Run following commands to insert settings into /var/svn/repositories/conf/svnserve.conf

cat >/var/svn/repositories/conf/svnserve.conf <<EOF
[general]
anon-access = none
auth-access = write
password-db = passwd
authz-db    = authz

[sasl]
EOF

Edit /var/svn/repositories/conf/passwd to add user and password.

Insert:

[users]
YOUR_USERNAME = YOUR_PASSWORD

Edit /var/svn/repositories/conf/authz to modify user permission.

Example:

[/]
YOUR_USERNAME = rw

[/example.com]
YOUR_USERNAME = rw
other = r</pre>

Note: r = read only; rw = read & write

Run following commands to create a xinetd configuration file for Subversion at /etc/xinetd.d/svnserve

cat >/etc/xinetd.d/svnserve <<EOF
service svn
{
        port        = 3690
        socket_type = stream
        protocol    = tcp
        wait        = no
        user        = svn
        server      = /usr/bin/svnserve
        server_args = -i -r /var/svn/repositories
}
EOF

Restart xinetd, and you are done.

/etc/init.d/xinetd restart

Final Check

Make sure Subversion is running using following command:

netstat -ant | grep ':3690'

You should see something like this if Subversion is running:

tcp        0      0 0.0.0.0:3690            0.0.0.0:*               LISTEN

Remember to open port 3690 if you have firewall installed.

You can now access your Subversion repository using svn://YOUR_HOST/ from any SVN client.

Want to contribute ?

You could earn up to $300 by adding new articles