Configuring a subversion repository over DAV authentication [18 May 2009]
Needs:
- Debian >=4.0 (or Ubuntu >=7.04)
- apache2 installed
Step 1: installing packages
First you need to install the following packages:
- the subversion software
# apt-get install subversion
- the apache2 support for subversion
# apt-get install libapache2-svn
Step 2: creating a svn repository
Locate in your favorite directory, eg /srv/, and create a folder for your future svn repositories. I will name it 'mysvn'.
# makedir mysvn
Now change position into mysvn directory and create a folder with the svn repository for your new project. I will create a 'test' repository.
# cd /srv/mysvn # mkdir test
Now it's time to install the repository.
# svnadmin create /srv/mysvn/test
Step 3: set-up apache
Step 3.1: enabling DAV
# a2enmod dav
Step 3.2: creating an authorized users file
Create an empty text file in which you will save your valid users and passwords. I will use /etc/apache2/users-svn.
# > /etc/apache2/users-svn
Now add a user and his/her password. I will create user 'pippo':
# htpasswd /etc/apache2/users-svn pippo
The system will ask you to type twice the password for pippo. In that file you will find a line similar to:
# cat /etc/apache2/users-svn pippo:3nx4Dlg.S.ERY
Where pippo is the user and the string after ':' is the md5 of your password.
!Tips:
- Run the same command for each new user.
- If you run htpasswd using the name of an existing user you will override the old password
- Instead of creating the file the first time you run htpasswd you can use '-c' option. Care: if you use this option on an existing file you will completely override it.
Step 3.3: apache2 configuration
Add the following code into your apache2 configuration file. The file is something like /etc/apache2/sites-available/default or /etc/apache2/sites-available/default-ssl, it depends on using or not SSL and on apache/Debian version. The file could also be something like /etc/apache2/sites-available/www.mysite.com: it depends on wich website this svn resource will be available for. Add:
<Location /myrepo> DAV svn SvnPath /srv/mysvn/test ForceType text/plain AuthType Basic AuthName "My test Repository - Login" Require valid-user AuthUserFile /etc/apache2/users-svn </Location>
It means that on http://www.mysite.com/myrepo apache will make you find the repository.
Step 3.4
Last, you need to grant to apache full access to the repository. Type:
# chown -R www-data\: /srv/mysvn/test
Step 3.5
Restart apache
# /etc/init.d/apache2 restart
