Subversion/WebDAV
From Gentoo Linux Wiki
This article will give you a basic overview of a Subversion, WebDAV and Apache configuration, entailing a scenario of subversion repositories located at /var/svn/, Apache2 web access through Https://foo.bar/svn, WebSVN at Https://foo.bar/websvn, no individual ACLs or vhosts.
[edit] Requirements
You need a working SVN-Server (dev-util/subversion, see Subversion/Install) and Apache (www-servers/apache). Subversion has to be compiled with the apache2 and webdav-neon USE-flags enabled. If you need a webinterface you should also merge www-apps/websvn.
[edit] Configuration
To create /var/svn, run,
Add apache to svnusers,
Add the following APACHE2_OPTS options in /etc/conf.d/apache2,
...
APACHE2_OPTS="${APACHE2_OPTS} -D SVN -D SVN_AUTHZ -D DAV -D DAV_FS"
The file /etc/apache2/modules.d/47_mod_dav_svn.conf should already exist, replace/edit the lower part,
<IfDefine SVN>
LoadModule dav_svn_module modules/mod_dav_svn.so
<IfDefine SVN_AUTHZ>
LoadModule authz_svn_module modules/mod_authz_svn.so
</IfDefine>
<Location /svn>
DAV svn
SVNParentPath /var/svn
AuthType Basic
AuthName "Subversion repository"
AuthUserFile /etc/svnusers
Require valid-user
SSLRequireSSL
</Location>
<Location /websvn>
AuthType Basic
AuthName "Subversion repository"
AuthUserFile /etc/svnusers
Require valid-user
SSLRequireSSL
</Location>
</IfDefine>
SSLRequireSSL is optional but as you should know HTTPS is always a good idea...
Add the following line to /var/www/localhost/htdocs/websvn/include/config.php
...
$config->parentPath('/var/svn/');
...
You can also set the default language, theme, etc. etc. here.
Use htpasswd to create an account,
Don't forget to restart apache.
[edit] Repository Creation Script
Aside the default configuration, your apache2 server needs read-write permissions for WebDAV. You can have the following script take care of this for you,
#!/bin/bash
#Dependencies:
#app-shells/bash (bash)
#sys-apps/coreutils (mktemp,...)
#dev-util/subversion (svn,svnadmin)
if [ ! -d /var/svn/ ] ;then
echo "Cant find SVN-Directory at /var/svn"
exit 1
fi
if [ -z $1 ] ;then
echo "Usage: $0 <Repository-Name>"
exit 1
fi
if [ -d /var/svn/$1 ] ;then
echo "Repository /var/svn/$1 is already present"
exit 1
fi
echo "Creating Repository..."
svnadmin create /var/svn/$1
echo "Creating default directories..."
TDIR=`mktemp -d`
cd $TDIR
mkdir -p {trunk,tags,branches}
echo "Initial import..."
svn import -q -m "Initial Import" --non-interactive $TDIR file:///var/svn/$1
echo "Fixing permissions..."
chown -R apache /var/svn/$1
echo "Cleaning up..."
rmdir $TDIR/{trunk,tags,branches}
rmdir $TDIR
echo "Done!"
Set the executable bit,
and run it.
This script is based on the Repmin script.