1.安装
CentOS通过yum安装subversion,先登录服务器,使用如下命令安装subversion
[root@mair-001 ~]# yum install subversion
subversion默认安装在/bin/目录下,如下查看命令
[root@mair-001 /]# which svnserve
/usr/bin/svnserve
检查subversion是否安装成功,如下命令
[root@mair-001 /]# 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.
[root@mair-001 /]#
显示 以上信息,说明subversion已安装完成,版本号是1.7.14
2.建立版本号
subversion默认以/var/svn作为数据根目录,可以通过/etc/sysconfig/svnserve修改这个默认位置,先查看下svnserve.service文件,如下,发现EnvironmentFile=/etc/sysconfig/svnserve
[root@mair-001 /]# systemctl cat svnserve.service
# /usr/lib/systemd/system/svnserve.service
[Unit]
Description=Subversion protocol daemon
After=syslog.target network.target
[Service]
Type=forking
EnvironmentFile=/etc/sysconfig/svnserve
ExecStart=/usr/bin/svnserve --daemon --pid-file=/run/svnserve/svnserve.pid $OPTIONS
[Install]
WantedBy=multi-user.target
[root@mair-001 /]#
查看/etc/sysconfig/svnserve文件内容
[root@mair-001 /]# cat /etc/sysconfig/svnserve
# OPTIONS is used to pass command-line arguments to svnserve.
#
# Specify the repository location in -r parameter:
OPTIONS="-r /var/svn
修改/etc/sysconfig/svnserver将默认目录指定到/opt/svn
[root@mair-001 /]# cat /etc/sysconfig/svnserve
# OPTIONS is used to pass command-line arguments to svnserve.
#
# Specify the repository location in -r parameter:
OPTIONS="-r /opt/svn"
[root@mair-001 /]#
使用svnadmin建立版本库mairuan
[root@mair-001 /]# mkdir -p /opt/svn
[root@mair-001 /]# svnadmin create /opt/svn/mairuan
查看mairuan文件目录信息
[root@mair-001 /]# ls /opt/svn/mairuan
conf db format hooks locks README.txt
3.配置
编辑passwd文件,新增用户longwentao
[root@mair-001 mairuan]# vi conf/authz
[users]
longwentao = longwentaopwd
编辑权限文件authz,用户longwentao设置可读写权限
[/]
longwentao = rw
编辑svnserve.conf
$ cat /opt/svn/mairuan/conf/svnserve.conf
[general]
anon-access = none #控制非鉴权用户访问版本库的权限
auth-access = write #控制鉴权用户访问版本库的权限
password-db = passwd #指定用户名口令文件名
authz-db = authz #指定权限配置文件名
realm = mairuan #指定版本库的认证域,即在登录时提示的认证域名称
4.SVN服务
启动SVN服务
[root@mair-001 mairuan]# systemctl start svnserve.service
检查SVN服务是否启动成功
[root@mair-001 mairuan]# ps aux | grep svn
root 11090 0.0 0.0 162200 896 ? Ss 17:20 0:00 /usr/bin/svnserve --daemon --pid-file=/run/svnserve/svnserve.pid -r /opt/svn
root 11092 0.0 0.0 112660 972 pts/0 R+ 17:21 0:00 grep --color=auto svn
[root@mair-001 mairuan]#
通过netstat可以看到SVN打开了3690端口
[root@mair-001 mairuan]# netstat -tnlp | grep svn
tcp 0 0 0.0.0.0:3690 0.0.0.0:* LISTEN 11090/svnserve
设置开机启动
[root@mair-001 mairuan]# systemctl enable svnserve.service
5.客户端测试
客户端可以通过TortoriseSVN测试