Install Apache/Subversion on Debian Lenny and Migrate the Repositories

Install Subversion/Apache

sudo aptitude install subversion apache2 libapache2-svn

Subversion Configuration

Create subversion repositories:

sudo mkdir /var/svn
sudo chown -R www-data:www-data /var/svn

All our subversion repositories should be located in /var/svn in order to be visible to Apache (you can change /var/svn to any directory).

SSL (Secure Sockets Layer)

The following steps are required if you need SSL, otherwise skip this chapter.

sudo aptitude install openssl ssl-cert
a2enmod ssl

“Listen 443″ should already exist in /etc/apache2/ports.conf, otherwise add it manually:

sudo vi /etc/apache2/ports.conf

Create a new SSL config file (replace ssl.new.site with your preferred name):

sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/ssl.new.site

Edit the file:

sudo vi /etc/apache2/sites-available/ssl.new.site

Replace:

<VirtualHost *:80>

with

<VirtualHost *:443>

Before </VirtualHost>, add:

SSLEngine on
SSLCertificateFile /etc/apache2/ssl/ssl.new.site.pem

You can try using the template from “default-ssl” instead of “default”, which is easier and more reliable since many SSL-related configurations are already handled. However, I haven’t tried this method and I’m not sure if it works without modifications.

Create SSL certificate file:

sudo mkdir /etc/apache2/ssl
sudo make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/ssl/ssl.new.site.pem

Enable the new site:

sudo a2ensite ssl.new.site
sudo /etc/init.d/apache2 reload

To see if the setup works, use your web browser to visit:

https://server.ip/

Replace server.ip with the ip of your server.
There should be a pop-up or an alert about the new certificate.

DAV_SVN Configuration

Edit /etc/apache2/mods-available/dav_svn.conf and follow the guidline:

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

Normally it looks like this:

<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>

Enable the mod and restart:

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

Create a user account for dav_svn:

sudo htpasswd -c /etc/apache2/dav_svn.passwd user1

To add more users, use:

sudo htpasswd /etc/apache2/dav_svn.passwd user2

Subversion Testing

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

svn co https://new.site/svn/test

It should says “Checked out revision 0.”, otherwise try looking for the errors on the Internet.
You probably forgot some steps or I forgot to mention some details.

Migration

Skip this chapter if you don’t need to migrate you data from your old server.

On the old server, we need to dump all updates into a single file. Each repository must be done separately.

mkdir svndump
cd svndump

sudo svnadmin dump /var/svn/repository > ./repository.dump

cd ..
tar zcvf svndump.tgz svndump
scp svndump.tgz username@new.server.ip:./

Those dump files must be applied on the new system’s repositories.

tar zxvf svndump.tgz
cd /var/svn/repository

sudo svnadmin create repository-name
sudo svnadmin load repository-name < ~/svndump/repository.dump

sudo chown -R www-data:www-data /var/svn/*

Congratulations, all your source code has been migrated!

This entry was posted in How-to and tagged , , , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

11 Comments

  1. Posted 02.09.2009 at 04:24 | Permalink

    Like this theme, nice one.

  2. rougher
    Posted 06.11.2009 at 01:11 | Permalink

    Yes! Thank U so much. Super Tutorial. Works fine for me.

  3. Posted 13.11.2009 at 15:19 | Permalink

    You’re welcome. I’m glad that you like it :)

  4. Yangs
    Posted 21.12.2009 at 15:18 | Permalink

    Really usefull.

    Thank you.

  5. Posted 18.03.2010 at 15:42 | Permalink

    Excellent, best guide out there! Thanks a million

  6. Nicolas GIRARDIN
    Posted 15.04.2010 at 21:33 | Permalink

    Thanks fo this great tutorial, I have my first SVN server running… :)

  7. Oliver
    Posted 17.04.2010 at 12:17 | Permalink

    Very good, saved me a lot of time, thanks!!

  8. Christophe
    Posted 14.06.2010 at 22:57 | Permalink

    Very nice tutorial !

  9. Posted 30.06.2010 at 10:27 | Permalink

    Many thanks to you guys for the responses!
    :D

  10. Reedz
    Posted 06.07.2010 at 20:38 | Permalink

    Hello , I followed that tutorial but unfortunately I get a “403 Forbidden error PROPFIND”. does anyone got the same ?

    Thanks

  11. Posted 08.07.2010 at 10:57 | Permalink

    That could be a permission error. Try `sudo chown -R www-data:www-data /var/svn/*`

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>