1、安装svn
# yum install subversion
# svnserve --version
svnserve, version 1.7.14 (r1542130)
compiled Jun 9 2014, 18:54:44
Copyright (C) 2013 The Apache Software Foundation.
This software consists of contributions made by many people; see the NOTICE
file for more information.
Subversion is open source software, see http://subversion.apache.org/
The following repository back-end (FS) modules are available:
* fs_base : Module for working with a Berkeley DB repository.
* fs_fs : Module for working with a plain file (FSFS) repository.
Cyrus SASL authentication is available.
2、创建目录及库
创建svn资源库目录
# mkdir -p /svn/svnrepos
创建svn资源库
# svnadmin create /svn/svnrepos
3、修改配置文件
# cd /svn/svnrepos
# ll
total 16
drwxr-xr-x 2 root root 51 Nov 7 15:15 conf
drwxr-sr-x 6 root root 4096 Nov 7 15:15 db
-r--r--r-- 1 root root 2 Nov 7 15:15 format
drwxr-xr-x 2 root root 4096 Nov 7 15:15 hooks
drwxr-xr-x 2 root root 39 Nov 7 15:15 locks
-rw-r--r-- 1 root root 229 Nov 7 15:15 README.txt
# cd conf/
有下面配置文件
# ll
total 12
-rw-r--r-- 1 root root 1080 Nov 7 15:15 authz
-rw-r--r-- 1 root root 309 Nov 7 15:15 passwd
-rw-r--r-- 1 root root 3090 Nov 7 15:15 svnserve.conf
authz文件是权限控制文件
passwd是帐号密码文件
svnserve.conf SVN服务配置文件
备份配置文件
# cp svnserve.conf svnserve.conf.bak
编辑服务配置文件,打开相应注释
# vi svnserve.conf
[general]
anon-access = none
auth-access = write
password-db = passwd
authz-db = authz
含义依次为:
非鉴权用户没有权限
鉴权用户有写权限
指定用户名口令文件名
指定权限配置文件名
添加admin账户和密码
# vi passwd
[users]
admin=admin
为admin账户配置根的读写权限
# vi authz
[groups]
[/]
admin = rw
4、启动服务查看状态
启动服务
# svnserve -d -r /svn/svnrepos
查看进程
# ps -ef | grep svn | grep -v grep
root 6563 1 0 15:28 ? 00:00:00 svnserve -d -r /svn/svnrepos
查看端口
# netstat -an | grep 3690
tcp 0 0 0.0.0.0:3690 0.0.0.0:* LISTEN
5、访问svn
使用tortoiseSVN进行访问,地址svn://192.168.1.177/svnrepos
账户admin,密码admin,就是passwd文件里写入的用户名和密码。
6、进一步探索
杀掉进程
# killall svnserve
删除资源库
# rm -rf /svn/svnrepos
# svnadmin create /svn/repositoryA
# vi /svn/repositoryA/conf/svnserve.conf
[general]
anon-access = read
auth-access = write
password-db = /svn/repositoryA/conf/passwd
authz-db = /svn/repositoryA/conf/authz
realm = repositoryA
# vi /svn/repositoryA/conf/passwd
[users]
user1 = user1pw
user2 = user2pw
user3 = user3pw
user4 = user4pw
# vi /svn/repositoryA/conf/authz
[groups]
team1 = user1,user2
team2 = user3,user4
[/]
@team1 = rw
[/]
@team2 = r
* =
# svnserve -d -r /svn/repositoryA
svn://192.168.1.177/repositoryA
测试:
本地创建文件,右键文件--TortoiseSVN--Import
输入url地址:svn://192.168.1.177/repositoryA
输入user3和user4,发现上传失败
输入user1和user2,上传成功
点击 开始--TortoiseSVN Repository Brower
输入url地址:svn://192.168.1.177/repositoryA
发现四个用户都可以访问,查看上传的文件,这是因为user3和user4权限为只读。
依照之前的操作添加一个版本库repositoryB
这里需要注意的是默认svn对应的端口为3690,所以另外添加版本库也需要指定不一样的端口
# svnserve -d -r /svn/repositoryB --listen-port 3691
url地址:svn://192.168.1.177:3691/repositoryB
参考:
https://blog.csdn.net/RobertoHuang/article/details/55504260
https://www.cnblogs.com/chaichuan/p/3758173.html
https://blog.csdn.net/u011280484/article/details/50499534
https://baijiahao.baidu.com/s?id=1587378965903945354&wfr=spider&for=pc