- 安装subversion
yum -y install subversion
- 创建两个项目目录
mkdir -p /svnrepos/Project1 mkdir -p /svnrepos/Project2
- 用svnadmin命令创建两个svn资源项目
svnadmin create /svnrepos/Project1 svnadmin create /svnrepos/Project2
- 为了使两个项目用同一套配置文件,我们将配置文件放到/svnrepos/目录下
cp -r /svnrepos/Project1/conf /svnrepos/conf
- 配置passwd,添加用户名和密码,用户名密码用等号分开
cd /svnrepos/conf vim passwd
[users]
# harry = harryssecret
# sally = sallyssecret
lixia = lixia
yushushu = yushushu
chenlei = chenlei
zouxinru = zouxinru
caoxiaoying = caoxiaoying
chenbaoyu = chenbaoyu
liuyuchen = liuyuchen
liaoxiaoxue = liaoxiaoxue
wangtianyu = wangtianyu
huangzhonghua = huangzhonghua
- 配置授权文件
vim authz
[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe
admin = lixia,yushushu
dev = yushushu,chenlei,zouxinru,wangtianyu
test = caoxiaoying,chenbaoyu
res = huangzhonghu
#Project1
[Project1:/]
@admin = rw
* = r
[Project1:/dev]
@admin = rw
@dev = rw
* = r
[Project1:/test]
@admin = rw
@test = rw
* = r
[Project1:/res]
@admin = rw
@res = rw
* = r
#Project2
[Project2:/]
@admin = rw
* = r
[Project2:/dev]
@admin = rw
@dev = rw
* = r
- 为了不产生混淆,这里删除/svnrepos/conf/svnserve.conf
rm -f /svnrepos/conf/svnserve.conf
- 配置项目一的svnserve.conf
cd /svnrepos/Project1/conf vim svnserve.conf
8 [general]
9 ### These options control access to the repository for unauthenticated
10 ### and authenticated users. Valid values are "write", "read",
11 ### and "none". The sample settings below are the defaults.
12 anon-access = none
13 auth-access = write
14 ### The password-db option controls the location of the password
15 ### database file. Unless you specify a path starting with a /,
16 ### the file's location is relative to the directory containing
17 ### this configuration file.
18 ### If SASL is enabled (see below), this file will NOT be used.
19 ### Uncomment the line below to use the default password file.
20 password-db = /svnrepos/conf/passwd
21 ### The authz-db option controls the location of the authorization
22 ### rules for path-based access control. Unless you specify a path
23 ### starting with a /, the file's location is relative to the the
24 ### directory containing this file. If you don't specify an
25 ### authz-db, no path-based access control is done.
26 ### Uncomment the line below to use the default authorization file.
27 authz-db = /svnrepos/conf/authz
28 ### This option specifies the authentication realm of the repository.
29 ### If two repositories have the same authentication realm, they should
30 ### have the same password database, and vice versa. The default realm
31 ### is repository's uuid.
32 # realm = My First Repository
将12,13,20,27行的注释去掉,并将anon-access = read改为anon-access = none,注意,这里每行前面都不能有空格,否则认证不通过
- 安装相同的方式配置项目二的svnserve.conf,当然也可以直接复制
cp /svnrepos/Project1/conf/svnserve.conf /svnrepos/Project2/conf/svnserve.conf
- 启动svnserve服务
svnserve -d -r /svnrepos/
- 查看svnserve服务是否启动成功
netstat -tnlp
tcp 0 0 0.0.0.0:3690 0.0.0.0:* LISTEN 3446/svnserve
如果看到3690,则说明启动成功了
- 停止svnserve服务
killall svnserve
至此,SVN服务器搭建完毕!