Tuesday, February 19, 2008

Set SVN server with Apache on Windows

(Feb 19, 2008)

We can download subversion zip package and just expand it some where. Then, copy mod_dav_svn.so to Apache's module directory. To prevent confusion, I copied it to modules/svn directory. Next, add this line to httpd.conf

LoadModule dav_svn_module modules/svn/mod_dav_svn.so
LoadModule authz_svn_module modules/svn/mod_authz_svn.so

Finally, uncomment this line in the config file to allow dav. Note that this line must come before dav_svn_module line

LoadModule dav_module modules/mod_dav.so

But wait, this just makes Apache load itself with SVN capability. We need to config SVN server and create repository too. Also note that we should not assign the document root to the root of repository to avoid name conflicts. If name conflicts occur, we will normally get Error 301.

The best practice of configure SVN server is at http://svn.spears.at/. I claimed it the best practice since it elegantly separate SVN configuration from other of Apache by using an Include command :
Include c:/etc/subversion.conf

In subversion.conf, we may enter some thing like this:

<Location /super_angel>
DAV svn
SVNPath E:/svn_repos/super_angel

AuthType Basic
AuthName "Subversion Super-Angel repository"
AuthUserFile c:/etc/svn-auth-file

Require valid-user

AuthzSVNAccessFile c:/etc/svn-acl

This will create a virtual address at localhost:8080/super_angel. This virtual address will be mapped to E:/svn_repos/super_angel, which is an actual repository for a project. Thus, we need to create a repository there using a command:
svnadmin create --fs-type bdb E:/svn_repos/super_angel

Next, we need to create an authentication password file. If the file is to be a brand new one, the command will have a c flag:
htpasswd -cm C:\etc\svn-auth-file john

For additional users, a command will be
htpasswd -m C:\etc\svn-auth-file Jane

Finally, we need to assign usage rights and groups for users in svn-acl file. The content of the file will look like this.
# specify groups here
team1 = moo, pinyotae

# team1 group has a read/write access to project1 repository
# all subdirectories
# all others have read access only
@team1 = rw
* = r

This will ready our Apache. We just need to restart it and access our repository at the virtual address we specify earlier.

Note: svn-acl is actually flexible. Please refer to http://svn.spears.at/ for more details.

No comments: