Trikks

The digital adventures of Eric Herlitz

Setup a subversion (svn) server in Debian

Posted by trikks on June 15, 2010

There are quite a few guides and howto’s out there. Some a relevant but as usual most of them are crap and made without any regards to the one who will use them. Compatibility and usability should always be ranked high when setting up such an environment.

One such thing is how to access the svn-server, there are these fancy ssh+svn://blabla which undoubtedly tightens the security by encrypting the connection in a pretty sophisticated manner. However the setup is complex and the usability disappears for “normal” users.

The way to go is by http or https, I promise :)
The compatibility with applications and platforms are unmatched, and the set up is fairly easy!

Lets start

Installation

# Install required packages
$ sudo apt-get install subversion libapache2-svn

# Create subversion repositories:
sudo mkdir /var/svn
sudo chown -R www-data:www-data /var/svn

# Edit the DAV_SVN Configuration
$ sudo nano /etc/apache2/mods-available/dav_svn.conf

It should look somethink like this (the dav_svn.conf file that is)

# IMPORTANT!
# remove the # in front of the <location and </location
<Location /svn>
DAV svn
SVNParentPath /var/svn
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user
#SSLRequireSSL      # this line must be added if you want SSL enabled
</Location>

Let’s set up the Apache-server mod and create a repository

# Enable modules and restart 

$ sudo a2enmod dav_svn
$ sudo /etc/init.d/apache2 restart

# Create/enable a user account for dav_svn (the -c indicates the main user)
# Replace user1 with the adminname
$ sudo htpasswd -c /etc/apache2/dav_svn.passwd user1

# Next user2, user3, user4 etc...
$ sudo htpasswd /etc/apache2/dav_svn.passwd user2

# Testing
$ sudo svnadmin create /var/svn/test
$ sudo chown -R www-data:www-data /var/svn/test

# Testing (first enter local user password, then your svn user/pass)
$ svn co http://localhost/svn/test

To create new repositories just login and type

$ sudo svnadmin create /var/svn/myrepository
$ sudo chown -R www-data:www-data /var/svn/myrepository

To connect to your svn, simply type http://yourserverurl/svn/myrepository. This can be done in either a browser or svn-application like tortoise or versions (there are quite a few).

Happy versioning!

About these ads

8 Responses to “Setup a subversion (svn) server in Debian”

  1. Omer Sabic said

    Great, worked like a charm… Except SSLRequireSSL which my server said was not a recognizable directive.. ?

  2. Rootserver said

    Mietserver…

    Setup a subversion (svn) server in Debian « Trikks…

  3. Matheus said

    Hello trikks.

    After trying to setup a subversion repository on my Ubuntu since 1 month and a half, your tutorial worked like a charm! Many thanks!

    By the way, could I translate your tutorial to Portuguese? After months searching, your tutorial is the only one I’ve found that worked perfectly .

    Cheers,
    Matheus.

    • trikks said

      Cool.

      Translate as you like, it’d be nice if you could post a link to my original post if I make any changes in the feature!

      / T.

  4. karhan said

    Hey thanks for the help.

    I have a dilemma though. This works well with http however I get errors when I try to use ssh+svn with it due to permission errors. What would be the best way to make sure that either ssh or the apache method works well together on the same repo?

    thanks

  5. […] Moving a Subversion Repository to Another Server Setup a subversion (svn) server in Debian […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

%d bloggers like this: