使用root用户登录系统,否则执行以下命令前面加上 sudo
一, 安装subversion
yum install -y subversion
二,查看安装的subversion 的安装位置
rpm -ql subversion
三,创建版本库
默认的地址为 /var/svn,可以修改 /etc/sysconfig/svnserve,我这里就不修改了,用默认的目录,
mkdir -p /var/svn
svnadmin create /var/svn/cloud
四,配置
进入conf目录(该svn版本库配置文件)
- authz文件是权限控制文件
- passwd是帐号密码文件
- svnserve.conf SVN服务配置文件
4.1 修改 passwd
vim passwd
在这个文件里加上以下内容 ,完整配置如下:
[root@node-4 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
#
jack = 123456
test = 123456
vim authz
[root@node-4 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,
### - a group of users defined in a special [groups] section,
### - an alias defined in a special [aliases] section,
### - all authenticated users, using the '$authenticated' token,
### - only anonymous users, using the '$anonymous' token,
### - anyone, using the '*' wildcard.
###
### A match can be inverted by prefixing the rule with '~'. Rules can
### grant read ('r') access, read-write ('rw') access, or no access
### ('').
[aliases]
# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average
[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe
admin = jack
user = jack,test
[/]
@admin = rw
@user = rw
# [/foo/bar]
# harry = rw
# &joe = r
# * =
# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
[general]
anon-access = none
auth-access = write
password-db = passwd
authz-db = authz
realm = /var/svn/cloud
# force-username-case = none
[sasl]
# use-sasl = true
# min-encryption = 0
# max-encryption = 256
- anon-access = read #匿名用户可读
- auth-access = write #授权用户可写
- password-db = passwd #使用哪个文件作为账号文件
- authz-db = authz #使用哪个文件作为权限文件
- realm = /var/svn/svnrepos # 认证空间名,版本库所在目录
4.3 启动svn 版本库
svnserve -d -r /var/svn
在windows 系统上测试svn服务器,在某目录 上右击,选择SVN CheckOut... ,输入svn://ip/cloud,正常情况下就会弹出一个用户验证框,输入用户名和密码就可以checkout代码或上传代码
注:如果出错,显示 “ /var/svn/cloud/conf/svnserve.conf:19: Option expected ”,就是因为subversion读取配置文件svnserve.conf时,无法识别有前置空格的配置文件,配置项要顶格写。
配置完后,杀掉svnserve进程,再一次启动版本库:
svnserve -d -r /var/svn
在window上测试就ok了