Sunday, February 6, 2011

HTTP subversion access

The objective is restore the subversion repository URL space from my old web site. This will require making some subversion repositories available over HTTP using Apache 2.2. Authentication is required only for updates. Access to the repositories should be configured in the virtual host, and not globally.

The environment for the directions is Ubuntu 10.10 (Maverick Meerkat) Desktop freshly installed and updates done.

This example is for exposing multiple repositories under /svn in the URL space of a virtual host.

Install apache with the subversion module, and subversion:
sudo apt-get install apache2 libapache2-svn subversion

Make a home for the physical subversion repositories.
sudo mkdir /var/svn

And create a few repositories accessable to the web server:
sudo svnadmin create /var/svn/repos
sudo chown -R www-data:www-data /var/svn/repos
sudo svnadmin create /var/svn/repos2
sudo chown -R www-data:www-data /var/svn/repos2

create some users for authenticaton
sudo touch /var/svn/passwd
sudo htpasswd -bm /var/svn/passwd user1 pass1
sudo htpasswd -bm /var/svn/passwd user2 pass2

create the access control file /var/svn/access
user1 = rw
* = r

user1 = rw
user2 = r
* =

Create a virtual host by creating /etc/apache2/sites-available/demo.local:
<VirtualHost *:80>
ServerName demo.local
ErrorLog ${APACHE_LOG_DIR}/demo.local-error.log
CustomLog ${APACHE_LOG_DIR}/demo.local-access.log combined

<Location /svn>
DAV svn
SVNParentPath /var/svn
SVNAutoVersioning On
AuthzSVNAccessFile /var/svn/access
Satisfy Any
Require valid-user
AuthType Basic
AuthName "Subversion repository"
AuthUserFile /var/svn/passwd


enable the virtual host
sudo a2ensite demo.local
sudo /etc/init.d/apache2 reload

At this point the repositories are available on the web server, and can be mounted using WebDAV. Extra details are in the SVN red book.

No comments:

Post a Comment