基本步骤:
1、安装必需的subversion
2、创建版本库
3、配置用户和权限
4、钩子和svn常用命令说明
一、安装subversion
在这里我们使用yum来安装subversion,使用以下命令即可完成。
[root@localhost ~]# yum -y install subversion
二、创建版本库
[root@localhost ~]# svnadmin create /var/www/svnroot
如果需要创建子版本库也可以使用 svnadmin create /var/www/svnroot/子版本库名称
的方式进行创建。但是要注意上级版本库中是否有文件夹叫这个名字,不然不重名冲突
三、版本库管理配置
进行刚才创建的版本库目录下的conf目录,可以看到有三个文件。
[root@localhost ~]# cd /var/www/svnroot/conf [root@localhost conf]# ls authz passwd svnserve.conf
svnserve.conf 这个是版本库的配置文件
passwd 这个是记录用户帐号密码的文件
authz 这个则是记录组、权限和身份验证的文件
1、配置svnserve.conf文件
这里需要设置以下几处
anon-access = none 指定匿名权限,默认为可读,现设置匿名无权限
auth-access = write 用户有写权限
password-db = passwd psswd文件地址 password-db 设置成 ../../passwd 这样可以方便统一管理
authz-db = authz 同上
注意去掉#注释以后配置一定要顶格写,下同。
[root@localhost conf]# vim svnserve.conf [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
2、配置passwd
该文件中记录svn用户名密码,以 (帐号 = 密码)或 (帐号 : 密码)的形式进行储存。
多用户之前用换行区分。这里配置了一个用户名为sgf密码为123456的svn 账户。
[root@localhost conf]# vim passwd ### This file is an example password file for svnserve. ### Its format is similar to that of svnserve.conf. As shown in the ### example below it contains one section labelled [users]. ### The name and password for each user follow, one account per line. [users] # harry = harryssecret # sally = sallyssecret sgf = 123456
3、authz文件的配置
[groups]表用于用户组的配置例如
“group1 = sgf,sgf2”这样就将这2个用户方在了group1 组织之中。
建立组是为了方便给一组相同权限的用户分配权限。
[/] 指定是svn的根版本库
版本库目录格式:
[<版本库>:/项目/目录]
@<用户组名> = <权限>
<用户名> = <权限>
[root@localhost conf]# vim authz ### 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 # [/foo/bar] # harry = rw # * = # [repository:/baz/fuz] # @harry_and_sally = rw # * = r [/] sgf = rw * =
这样svn版本库就算配置完成了。
运行 svn
[root@localhost ~]# svnserve -d -r /var/www/svnroot