Thursday, September 6, 2007

svn and apache

apt-get install apache2 subversion libapache2-svn libapache2-mod-php5 libapache2-svn

# <Location URL> ... </Location>
# URL controls how the repository appears to the outside world.
# In this example clients access the repository as http://hostname/svn/
# Note, a literal /svn should NOT exist in your document root.
<Location /svn>

# Uncomment this to enable the repository
DAV svn

# Set this to the path to your repository
#SVNPath /var/lib/svn
# Alternatively, use SVNParentPath if you have multiple repositories under
# under a single directory (/var/lib/svn/repo1, /var/lib/svn/repo2, ...).
# You need either SVNPath and SVNParentPath, but not both.
SVNParentPath /var/lib/svn

# Access control is done at 3 levels: (1) Apache authentication, via
# any of several methods. A "Basic Auth" section is commented out
# below. (2) Apache <Limit> and <LimitExcept>, also commented out
# below. (3) mod_authz_svn is a svn-specific authorization module
# which offers fine-grained read/write access control for paths
# within a repository. (The first two layers are coarse-grained; you
# can only enable/disable access to an entire repository.) Note that
# mod_authz_svn is noticeably slower than the other two layers, so if
# you don't need the fine-grained control, don't configure it.

# Basic Authentication is repository-wide. It is not secure unless
# you are using https. See the 'htpasswd' command to create and
# manage the password file - and the documentation for the
# 'auth_basic' and 'authn_file' modules, which you will need for this
# (enable them with 'a2enmod').
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.passwd

# To enable authorization via mod_authz_svn
AuthzSVNAccessFile /etc/apache2/dav_svn.authz

# The following three lines allow anonymous read, but make
# committers authenticate themselves. It requires the 'authz_user'
# module (enable it with 'a2enmod').
Require valid-user

initialize a password file (to add users, remove the '-c'):
htpasswd -c /etc/apache2/dav_svn.passwd <username>
chown www-data.www-data /etc/apache2/dav_svn.passwd

create repository:
mkdir /var/lib/svn
chown www-data.www-data /var/lib/svn
svnadmin create /var/lib/svn/<repository>
chown -R www-data.www-data /var/lib/svn/<repository>

set permissions for repository in /etc/apache2/dav_svn.authz:
admin = foo
devs = foo, bar

@admin = rw

@devs = rw
someone = r

import a project:
cd /my/path/to/myproject
svn import --username <user> . http://my.domain/svn/<repository> -m "initial import"
svn co --username <user> http://my.domain/svn/<repository>

copy source to /var/www/wsvn and change /var/www/wsvn/wsvn.php:
$locwebsvnhttp = '/wsvn';

copy /var/www/wsvn/include/distconfig.php to /var/www/wsvn/include/config.php:

apt-get install enscript

RSS feeds are disabled above, but if you want to have feeds and the error "Error creating feed file, please check write permissions." appears:
chown -R www-data:www-data cache

at end of virtual host in /etc/apache2/sites-enabled/default:
# Location for WebSVN Interface
# the '/' behind /wsvn/ is important!!!
<Location /wsvn/>
Options MultiViews
DirectoryIndex wsvn.php
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user

/etc/init.d/apache2 force-reload

reverting (undo local changes):
svn revert --recursive .

No comments: