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>

Don’t forget to change /var/svn to your svn directory (thanks, D@vid).

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.

19 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/*`

  12. D@v1d
    Posted 07.02.2011 at 20:14 | Permalink

    Nice tutorial, exactly what I need.

    But I got an error:

    when I try to checkout I got this message:
    svn: Could not open the requested SVN filesystem

    Does anyone have an idea ?

    thanks

  13. D@v1d
    Posted 07.02.2011 at 23:29 | Permalink

    I found the problem….
    I forgot to change a line in the default dav_svn conf:

    I had
    SVNParentPath /var/lib/svn

    instead of
    SVNParentPath /var/svn

  14. Posted 11.02.2011 at 02:11 | Permalink

    Hi D@vid, thanks for the comments. I have updated the post in case other readers would have the same problem.

  15. wilson
    Posted 18.03.2011 at 19:08 | Permalink

    Just Perfect!!! really nice…
    How can I protect create files for specific users I mean restrict files…
    Thanks in advance.

  16. Posted 19.03.2011 at 04:31 | Permalink

    A brief guideline should be available in /etc/apache2/mods-available/dav_svn.conf
    For more explanation, try this.

  17. manu
    Posted 06.04.2011 at 13:59 | Permalink

    Hello,

    i Have the same error than D@v1d but my config file looks like good.

    I have the good path for my SVNParentPath

    if i try with my firefox with this adress : https://ip/svn it works

    I don’t understand what’s append

  18. Posted 08.04.2011 at 12:56 | Permalink

    @manu Tha’s weird. Probably dav_svn.conf or the passwd file is misconfigured.

  19. Melis
    Posted 30.05.2011 at 09:32 | Permalink

    Thank you..
    tutorial works for Debian Squeeze too..

One Trackback

  1. [...] Pré-requisitos: subversion previamente instalado e um repositório já criado, caso precise de um guia para a instalação e criação dos repositórios no SVN recomendo este tutorial: http://longspine.com/how-to/install-apachesubversion-on-debian-lenny-and-migrate-the-repositories/ [...]

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>