SVN: Setting up SVN w/ Apache

First of all, I should mention there are typically 2 ways to access SVN:
1. http://url.com
2. svn://url.com

The following steps helps you set up the directory access for method 1. Accessing through http protocol.

Step 1. Install Apache

Step 2. Install Subversion

Step 3. Set environment path=subversion/bin

Step 4. Edit Apache httpd.conf (module section). Add the following lines:

LoadModule dav_module modules/mod_dav.so
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so

Step 5. Copy the modules from Subversion/bin into Apache/modules

Step 6. Add new VirtualHost entry:

< VirtualHost ip:port>
   ServerAdmin webmaster@url.com
   DocumentRoot c:/wwwroot
   ServerName svn.url.com
   LogLevel warn
   ErrorLog logs/svn.url.com.error.log
   CustomLog logs/svn.url.com.access.log common

   < Location>
       DAV svn
       SVNParentPath c:/svnroot
       SVNListParentPath on
       AuthzSVNAccessFile c:/svnrepo/conf/authz
       AuthType Basic
       AuthName "Kronos SVN"
       AuthUserFile c:/svnrepo/conf/htpasswd
       Require valid-user
   < /Location>
< /VirtualHost>

Step 7. Customize authz file

[groups]
admin = bob, joe, mike
visitor = dan, steve, matt

[reponame:/]
* =
@admin = rw
@visitor = r

[reponame:/subdir/]
* =
@admin = rw
@visitor =

Step 8. Customize htpasswd file

use apache/bin/htpasswd.exe to create htpasswd file: htpasswd.exe -c /path/htpasswd user1
add aditional users to htpasswd file: htpasswd.exe /path/htpasswd user2

Step 9. Restart your apache server

To set up directory access for method 2, accessing through svn port directly is much simpler, but does not offer the encrypted password protection offered in method 1. The trick is, you can actually have BOTH.

For the admin account I like to use the http access w/ encrypted protection. For additional accounts, just to make things simpler, I use the svn passwd file which typically just looks like this:

[users]
user1=password1
user2=password2

Just make sure you adjust the svn configuration file accordingly & you should be all set. Restart your svn server after changing the configuration file.

No comments: