.Windows环境下基于Apache 的SVN 服务器配置过程及出现问题小结

1.Windows环境下 基于 Apache 的SVN 服务器 安装及配置
1.1安装
1.1.1安装Apache
(1)下载Apache
地址http://httpd.apache.org/download.cgi
注意:Apache低于2.0.54的Windows版本的存在编译问题,低于2.0.54的版本不能与Subversion 1.2一起工作。2.2.X目前不能很好支持SVN 1.4.3。当前建议下载Apache 2.0.59,我用的是2.0.63呵呵
   (2) 安装
下载完成后运行apache_2.0.63-win32-x86-no_ssl.msi ,根据提示进行操作。遇到系统要求输入SERVER的URL时, 如果你的服务器没有DNS名称,请直接输入IP地址,入我的机器IP就192.168.1.105,直接输入他就行了,以后配好后访问就可以用:svn://192.168.1.105/...来访问了。
   注意:如果你已经有了IIS或其他监听80段口的程序,安装会失败,如果发生这种情况,直接到程序的安装目录\Apache Group\Apache2\conf,打开httpd.conf。编辑文件的Listen 80为其他可用的端口,例如Listen 81,然后重新启动-这样就不会那个问题了。
  (3)检查
安装完成后浏览 http://localhost/ 若成功,可看到apache页面。

1.1.2安装Subversion
  (1)下载 Subversion
地址:http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=91
(2)安装
运行Setup-Subversion-1.5.6.msi 安装程序,并根据指导安装,如果Subversion认识到你安装了Apache,你就几乎完成了工作,如果它没有找到Apache服务器,你还有额外的步骤。
(3)后续
步骤1 从C:\Program Files\Subversion\bin 中将
mod_authz_svn.so mod_dav_svn.so复制到
C:\Program Files\Apache Group\Apache2\modules下
intl3_svn.dll libdb*.dll
C:\Program Files\Apache Group\Apache2\bin下
     步骤2 找到C:\Program Files\Apache Group\Apache2\conf\httpd.conf文件去掉如下几行的注释(删除 '#'标记):
#LoadModule dav_fs_module modules/mod_dav_fs.so
#LoadModule dav_module modules/mod_dav.so
将下面几行添加到LoadModule部分的最后。
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
  1.1.3安装TortoiseSVN

五、开始->运行->CMD->输入“svnadmin create --fs-type fsfs D:\svn\project1”建立SVN库
       D:\svn\project1这个路径可以任意定义
六、新建一个文本文件,内容为“svnserve -d -r D:\svn”,“D:\svn”为服务器根目录,保存并改名为“s.bat”,将它的快捷方式放入到“开始->程序->启动”目录里,让机器启动时自动运行这个文件,做用为启动SVN服务器,之后在局域网里的其它机器就可以使用上面的用户名和密码进行提交和检出了.

六、新建一个文本文件,内容为“svnserve -d -r D:\svn”,“D:\svn”为服务器根目录,保存并改名为“s.bat”,将它的快捷方式放入到“开始->程序->启动”目录里,让机器启动时自动运行这个文件,做用为启动SVN服务器,之后在局域网里的其它机器就可以使用上面的用户名和密码进行提交和检出了.

七、局域网里使用的路径为"svn://192.168.1.8/project1"就可以检出第三步我们建立的SVN库的内容了.
它包这种错误:

org.tigris.subversion.javahl.clientexeptin: Authorization failed

问题解决:
http://hi.baidu.com/tianfu_xue/blog/item/9dbfd6fa4d416d839f51462b.html

出现该问题基本都是三个配置文件的问题,下面把这个文件列出来。

svnserve.conf:
[general]
anon-access = read
auth-access = write
password-db = passwd
authz-db = authz

passwd:
[users]
harry = harryssecret

authz:
[groups]
[/]
harry = rw

出现authorization failed异常,一般都是authz文件里,用户组或者用户权限没有配置好,只要设置[/]就可以,代表根目录下所有的资源,如果要限定资源,可以加上子目录即可


迁移中SVN问题:svnadmin: 期望文件系统格式在“1”到“3”之间;发现格式“4”,原因是因为SVN库是用客户端创建,改为命令创建的库就ok了。


下面,我们来介绍authz这个文件,这个文件是控制权限的关键。
同样打开这个文件,你会看到一些注释掉的语句,
# [groups]
# [/foo/bar]
# [repository:/baz/fuz]
       下面,我们介绍一下用户组的概念。所谓用户组,顾名思义,就是一个成员组,一般情况下,在同一个成员组的人员享有同样的权力,比如读,写权。Subversion为我们提供了一个很好的用户组应用。
在之前,我们一共建立三个用户,nicholas,friend和stranger,我们现在设想一下我们的组情况,假设我们希望nicholas和friend在开发组中,这两个用户具有读和写的权力,而用户stranger在测试组中,只具备读的权力。那么我们该如何来控制这个权限呢?看看下面的代码:
我们先在[groups]标记下面,输入组的名称:
       dev_group = nicholas, friend
       test_group = stranger
到目前为止,我们已经为三个用户分好了用户组,其中nicholas和friend在dev_group中,而stranger则在test_group中。
下面,我们为两个组来分配权限。
首先我们要为这两个组所能访问的工程做一个规定,正如在之前的文章《Eclipse中使用Subversion进行版本控制》中,曾经向版本参考提交了一个名为“TestSVNProj”的项目,下面我就假设刚刚建立的两个用户组都需要最这个工程进行操作。
我们在authz文件中,写下[TestSVNProj],这个是指定我们下面将对TestSVNProj项目进行定义。
我们使用如下代码:
@dev_group = rw
@test_group = r
这就定义了,对TestSVNProj项目,dev_group用户组可以进行读,写操作,而test_group用户组则只具备读的权限。
为了阻止其他用户组对这个文件有读的权力,我们可以再添加一句:
* =
这个语句就是指定其他的用户组的权力为空,也就是没有权力。
### This file is an example authorization file for svnserve.
### Its format is identical to that of mod_authz_svn authorization
### files.
### As shown below each section defines authorizations for the path and
### (optional) repository specified by the section name.
### The authorizations follow. An authorization line can refer to a
### single user, to a group of users defined in a special [groups]
### section, or to anyone using the '*' wildcard. Each definition can
### grant read ('r') access, read-write ('rw') access, or no access
### ('').

[groups]
# harry_and_sally = harry,sally

dev_group = nicholas,friend
test_group = stranger

# [/foo/bar]
# harry = rw
# * =

# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r

[/TestSVNProj]
@dev_group = rw
@test_group = r
* =



最后,我们在来说说这个svnserve.conf文件,打开这个文件,我们就可以看出这个是Subversion权限配置的主文件,类似于读取相关信息的枢纽。
为了让我们刚刚配置的两个文件(passwd和authz)起作用,我们需要去掉password-db = passwd和authz-db = authz前面的注释符“#”,让Subversion知道要从上面两个文件中读取相关信息。
当然,你也可以指定其他的认证文件,写法如下:
        password-db = ..\..\passwd
authz-db = ..\..\authz
以此类推。
       在实战过程中,处于安全的考虑,我们往往要限制对匿名用户的访问权限,所以我们可以将anon-access = read前面的“#”去掉,并将read参数修改为none,表明禁止匿名用户对版本控制库的访问。
### This file controls the configuration of the svnserve daemon, if you
### use it to allow access to this repository. (If you only allow
### access through http: and/or file: URLs, then this file is
### irrelevant.)

### Visit http://subversion.tigris.org/ for more information.

[general]
### These options control access to the repository for unauthenticated
### and authenticated users. Valid values are "write", "read",
### and "none". The sample settings below are the defaults.
anon-access = none
# auth-access = write
### The password-db option controls the location of the password
### database file. Unless you specify a path starting with a /,
### the file's location is relative to the conf directory.
### Uncomment the line below to use the default password file.
password-db = passwd
### The authz-db option controls the location of the authorization
### rules for path-based access control. Unless you specify a path
### starting with a /, the file's location is relative to the conf
### directory. If you don't specify an authz-db, no path-based access
### control is done.
### Uncomment the line below to use the default authorization file.
authz-db = authz
### This option specifies the authentication realm of the repository.
### If two repositories have the same authentication realm, they should
### have the same password database, and vice versa. The default realm
### is repository's uuid.
# realm = My First Repository



       至此,你可以控制你的项目,对其进行访问权限的控制了。







猜你喜欢

转载自yaoyanzhu.iteye.com/blog/662014
今日推荐