Howto: Subversion with WebDAV and Websvn

Heute mal was auf Englisch:

After I searched this information for some hours today, here is it and I hope it is useful for someone.

This is how to integrate Subversion with Apache2, WebDAV and Websvn. The whole thing was done on debian, so you may have to adjust it a bit if you are working on a different platform. I assume you know what Subversion is - if you don’t, read the link.

First create your repositories and give it the appropiate rights. I use a new System-user for this purpose.
$ su
# adduser --system svn
# cd ~svn
# svnadmin create myRepo
# chown -R svn:www-data *
# chmod -R 775 *

Then set up a new vhost in your apache-config (I think this is debian-specific, so you may have to adjust this)
# vi /etc/apache2/sites-enabled/svn

this is an example configuration I first found here:
<VirtualHost 123.123.123.123:443>
ServerAdmin bla@blubb.com
ServerName svn.chief-architect.de
DocumentRoot /var/www/svn
LoadModule dav_module /usr/lib/apache2/modules/mod_dav.so
LoadModule dav_svn_module /usr/lib/apache2/modules/mod_dav_svn.so
LoadModule ssl_module /usr/lib/apache2/modules/mod_ssl.so
SSLEngine On
SSLCertificateFile /etc/apache2/ssl/apache.pem
<location /svn>
Order allow,deny
Allow from all
DAV svn
SVNParentPath /home/svn
AuthzSVNAccessFile /etc/apache2/auth-files/public-svn-authzfile
Satisfy Any
Require valid-user
AuthType Basic
AuthName "chief-architect.de Subversion Repository"
AuthUserFile /etc/apache2/auth-files/dav_svn.passwd
</location>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
</VirtualHost>

Then we need to create the accessfile:
# vi /etc/apache2/auth-files/public-svn-authzfile
Some sample config that defines a group of developers that get read/write-access:[groups]
developers = philip
[myRepo:/]
@developers = rw

Let’s add the user “philip”:
# touch /etc/apache2/auth-files/dav_svn.passwd
# chown www-data /etc/apache2/auth-files/dav_svn.passwd
# chmod 600 /etc/apache2/auth-files/dav_svn.passwd
# htpasswd -m /etc/apache2/auth-files/dav_svn.passwd philip
you will be prompted for a password and it will be stored md5-hashed.

Now the Subversion-Repository should be ready. So we test it:
# apache2ctl -k restart
No errors, I hope
# cd /root
# mkdir svntest
# cd svntest
# svn co https://[yourservername.here]/svn/myRepo
Enter your authentication data, when you are prompted and if no errors come up, your subversion-server is up and running. congratulations :-)

Now we integrate websvn (a php-application that allowes to browse the repositories with your webbrowser; I used Version 2.0rc1):
# mkdir /var/www/svn
# cd /var/www/svn
download the websvn-code and unpack it to a folder called “websvn” then go on:
# cd websvn/include
# cp distconfig.inc config.inc
# vi config.inc
Change the following things:
$config->parentPath("/home/svn");
$config->useMultiViews();
$config->useAuthenticationFile("/etc/apache2/auth-files/public-svn-authzfile");

Then:
# cd ..
# cp wsvn.php ../
# cd ..
# vi wsvn.php
Change the following:
$locwebsvnhttp = "/websvn";
$locwebsvnreal = "/var/www/svn/websvn";

Then:
# vi .htaccess
Add:
Options MultiViews
DirectoryIndex wsvn.php index.html index.cgi index.pl index.php index.xhtml

Then change the vhost-config:
# vi /etc/apache2/sites-enabled/svn
Add the following between right after the first </location>:
<location /wsvn/>
Order allow,deny
Allow from all
DAV svn
SVNParentPath /home/svn
AuthzSVNAccessFile /etc/apache2/auth-files/public-svn-authzfile
Satisfy Any
Require valid-user
AuthType Basic
AuthName "chief-architect.de Subversion Repository"
AuthUserFile /etc/apache2/auth-files/dav_svn.passwd
</location>

Then restart apache and hope that everything has gone well:
# apache2ctl -k restart

If there are no errors, point your browser to https://[yourServerName]/wsvn and you should see the websvn index-page, but without any repositories listet. Then go next to https://[yourServerName]/wsvn/myRepo. You should be asked for authentication. Enter the username and password you added before with the htpasswd-command. If all goes well, should now be able to browse your repository.

That’s it. I hope there are no big mistakes (but I fear there are because I wrote everything from memory). If you find some, leave a comment and I’ll see if I can correct it.


( ! ) Fatal error: Maximum execution time of 30 seconds exceeded in /home/philip/www/blog_philippreissing_com/wp-content/plugins/intensedebate/class.json.php on line 265
Call Stack
#TimeMemoryFunctionLocation
114.486720705524shutdown_action_hook( )../wp-settings.php:0
214.486720705564do_action( )../wp-settings.php:585
314.486920707052call_user_func_array ( )../plugin.php:339
414.486920707148id_ping_queue( )../plugin.php:0
514.619732883320id_queue->ping( )../intensedebate.php:347
614.619832883320id_queue->send( )../intensedebate.php:824
714.620132884840Services_JSON->encode( )../intensedebate.php:837
814.621932921608array_map ( )../class.json.php:394
940.687635862232Services_JSON->encode( )../class.json.php:0
1040.687735862232array_map ( )../class.json.php:409
1140.689135862232Services_JSON->name_value( )../class.json.php:0
1240.689135862232Services_JSON->encode( )../class.json.php:437
1340.689135862232array_map ( )../class.json.php:382
1440.690535862232Services_JSON->name_value( )../class.json.php:0
1540.690535862232Services_JSON->encode( )../class.json.php:437