1. 安装 SVN 服务端
在 CentOS 下使用 yum 命令可以很方便的完成安装 subversion
[root@localhost ~]# yum -y install subversion
测试是否安装完成 svnserve --version
svnserve, version 1.7.14 (r1542130)
compiled Apr 11 2018, 02:40:28
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 数据目录(默认 /var/svn 为数据根目录)
[root@localhost ~]# mkdir /var/svn
创建版本库 hello(名字可以任取)
[root@localhost ~]# svnadmin create /var/svn/hello
版本库的结构如下 sudo tree -L 2 /var/svn/hello
├── conf
│ ├── authz
│ ├── passwd
│ └── svnserve.conf
├── db
│ ├── current
│ ├── format
│ ├── fsfs.conf
│ ├── fs-type
│ ├── min-unpacked-rev
│ ├── revprops
│ ├── revs
│ ├── transactions
│ ├── txn-current
│ ├── txn-current-lock
│ ├── txn-protorevs
│ ├── uuid
│ └── write-lock
├── format
├── hooks
│ ├── post-commit.tmpl
│ ├── post-lock.tmpl
│ ├── post-revprop-change.tmpl
│ ├── post-unlock.tmpl
│ ├── pre-commit.tmpl
│ ├── pre-lock.tmpl
│ ├── pre-revprop-change.tmpl
│ ├── pre-unlock.tmpl
│ └── start-commit.tmpl
├── locks
│ ├── db.lock
│ └── db-logs.lock
└── README.txt
3. 配置版本库
1) 编辑 SVN 配置文件
[root@localhost ~]# vim /var/svn/hello/conf/svnserve.conf
修改为如下内容:
anon-access = none #(19)控制非鉴权用户访问版本库的权限
auth-access = write #(20)控制鉴权用户访问版本库的权限
password-db = passwd #(27)指定用户名口令文件名
authz-db = authz #(34)指定权限配置文件名
realm = hello #(39)指定版本库的认证域
2) 编译用户配置文件
[root@localhost ~]# vim /var/svn/hello/conf/passwd
添加用户信息:
[users]
# username = password
admin = pswd
temp = test
3) 编辑权限控制文件
[root@localhost ~]# vim /var/svn/hello/conf/authz
为用户分配目录与权限
[/] # /表示SVN仓库的根目路
admin = rw # 拥有根目录的读写权限
temp = r # 只有根目录的查看权限
[/temp]
temp = rw # 拥有/temp目录下的读写权限
4. 启动SVN服务
推荐使用 systemctl 操作服务管理器
[root@localhost ~]# systemctl restart svnserve.service
设置开机启动
[root@localhost ~]# systemctl enable svnserve.service
5. 关闭安全服务
1) 关闭防火墙
临时关闭防火墙
[root@localhost ~]# systemctl stop firewalld
禁止开机启动
[root@localhost ~]# systemctl disable firewalld
查看状态 sudo systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
2) 关闭 SeLinux
临时关闭内部安全机制
[root@localhost ~]# setenforce 0
编辑 SELINUX 配置文件
vim /etc/selinux/config
永久关闭(将 enforcing 改为 disable )
SELINUX=disable
查看状态 sudo /usr/sbin/sestatus
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: permissive
Mode from config file: error (Success)
Policy MLS status: enabled
Policy deny_unknown status: allowed
Max kernel policy version: 31
6. 使用 TortoiseSVN
选择一个空文件夹,鼠标右键点击 SVN checkout
在 URL of repository 中填写 svn 地址(CentOS IP地址使用 ifconfig 查看)
在验证框中填写用户账号与密码
最后弹出 Checkout Finished,表示 SVN 客户端已经可以正常使用了