依然灬灰

CentOS 7.3 安装SVN

2017/10/09

CentOS 7.3 安装SVN

安装SVN

YUM安装SVN

1
yum install subversion

测试安装是否成功

1
svnserve --version

出现以下信息安装成功

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@iZ2ze1jtxhkve7f07qko6nZ sshuser]# svnserve --version
svnserve, version 1.7.14 (r1542130)
compiled Aug 23 2017, 20:43:38
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.

代码库创建

创建存放数据文件夹

1
[root@localhost modules]# mkdir -p /opt/svn/repo

初始化测试库

1
[root@localhost modules]# svnadmin create /opt/svn/repo

执行上面的命令后,自动建立repo测试库,查看/opt/svn/repo 文件夹发现包含了conf, db,format,hooks, locks, README.txt等文件,说明一个SVN库已经建立。

配置代码库

进入上面生成的文件夹conf下,进行配置

1
[root@localhost modules]# cd /opt/svn/repo/conf

用户密码passwd配置

1
[root@admin conf]# vim passwd

修改passwd以下内容

1
2
3
4
5
6
7
8
9
10
[users]
# harry = harryssecret
# sally = sallyssecret
hello=123
用户名=密码
这样我们就建立了hello用户, 123密码
**以上语句都必须顶格写, 左侧不能留空格, 否则会出错.**

权限控制authz配置

1
[root@admin conf]# vim authz

目的是设置哪些用户可以访问哪些目录,向authz文件追加以下内容:

1
2
3
4
5
6
7
8
9
#设置[/]代表根目录下所有的资源
[/] 或者写成[repl:/]
hello = rw
意思是hello用户对repo测试库下所有的目录有读写权限,当然也可以限定。
如果是自己用,就直接是读写吧。
**以上语句都必须顶格写, 左侧不能留空格, 否则会出错.**

服务svnserve.conf配置

1
[root@admin conf]# vim svnserve.conf

追加以下内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
[general]
#匿名访问的权限,可以是read,write,none,默认为read
anon-access=none
#使授权用户有写权限
auth-access=write
#密码数据库的路径
password-db=passwd
#访问控制文件
authz-db=authz
#认证命名空间,subversion会在认证提示里显示,并且作为凭证缓存的关键字
realm=/opt/svn/repositories
**以上语句都必须顶格写, 左侧不能留空格, 否则会出错.**

启动SVN

默认端口号启动

1
[root@localhost conf]# svnserve -d -r /opt/svn/repo

设置自己需要的端口号

1
[root@localhost conf]# svnserve -d -r /opt/svn/repo --listen-port 3391

查看SVN是否启动

1
2
[root@localhost conf]# ps -aux |gerp svn
root 11413 0.0 0.0 162184 740 ? Ss Sep28 0:00 svnserve -d -r /opt/svn/repo

测试连接

本文参考
CentOS 7.0 SVN搭建 (YUM安装)