2009年4月9日 星期四

SVN + Apache 2.2 Authentication Set Up

I have tried twice to start up a simple svn server with either svnserve daemon or
apache module, even both.
But every time when I want to rebuild a server in different machines, I have to
waste my time looking up Internet resource. Therefore, I determined to write a easy document about the whole procedure just in case I should forget once again.


Platform: winxp sp3 & IBM X31

1.Download SVN binary with apache module from here

2.Download apache package and install it.
After installation, enter localhost to see if apache service works.

3.Copy bin/mod_dav_svn.so and bin/mod_authz_svn.so under svn installed directiry to the Apache modules directory.

4.Set system environment variable "path" to svn insatlled directory
subfolder "bin" and reboot so that svn support dll's are visible to
apache service.

5. Edit the Apache configuration file (httpd.conf) and make the following changes:

5a. Uncomment the following two lines:

#LoadModule dav_fs_module modules/mod_dav_fs.so
#LoadModule dav_module modules/mod_dav.so

5b. Add the following two lines to the end of the LoadModule section:

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

6. Add the following code snippet in th end of http.conf

# /svn_repos attribute refers to http uri.In
# this example, it should be http://localhost/svn_repos/

#
DAV svn
SVNParentPath D:/svn_repos/
# This indicates the absolute path where your
# respositories reside in your machine
# Apache authentication begins...
AuthType Basic
AuthName "Subversion repository"
AuthUserFile D:/svn_repos/apache_authz
# Generate this "apache_authz" with htpasswd tool under apache installed
# directory "bin" subfolder with following
# command:
# htpasswd -cm path to your file username
# ex. htpasswd -cm D:/svn_repos/apache_authz kinju
# -c option means "create" Next time when you want to
# add a new user, you should omit -c option like that
# htpasswd -m D:/svn_repos/apache_authz kinjuplus
# This program should prompt you to enter password twice.

Require valid-user
### apache auth end

### svn auth begin
# our access control policy
AuthzSVNAccessFile D:/svn_repos/svn_authz
# authentication if necessary
Satisfy Any
### svn auth end

#



7. Edit svn auth policy in configuration file
as you define in http.conf previously

[groups] #define group syntax: groupname = user1,user2,....
test-developers = kinju


[/:] #repository root
*= r
@test-developers = rw
[test:/] # "test repository"
*= r
@test-developers = rw

[test:/test] # A test folder under test repository
@test-developers = rw

[test2:/] #"test2 repository"
*= r
@test-developers = rw



Tips: You must create your repository with svnadmin command line tool like that
"svnadmin create --fs-type fsfs NewRepo."
On the contrary, creating a repository with TortoiseSVN(烏龜), you probably
will encounter a error. This is a bug dued to a compatibility issue in new
version of TortoiseSVN. Refer to here

沒有留言: