安装subversion
安装subversion
yum install subversion -y
subversion安装在/usr/bin目录
[root@nexus ~]# which svnserve
/usr/bin/svnserve
检查是否安装成功
[root@nexus ~]# 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.
配置版本库
查看subversion的配置文件位置为/etc/sysconfig/svnserve
[root@nexus ~]# 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
查看/etc/sysconfig/svnserve配置文件
[root@nexus ~]# 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"
默认的版本库位置为/var/svn,但实际不存在这个文件夹
所以需要新建
mkdir /var/svn
使用svnadmin建立版本库svn-hello
[root@nexus var]# svnadmin create /var/svn/svn-hello
[root@nexus var]# ll /var/svn/
total 4
drwxr-xr-x 6 root root 4096 Sep 7 08:45 svn-hello
[root@nexus var]# ll /var/svn/svn-hello/
total 24
drwxr-xr-x 2 root root 4096 Sep 7 08:45 conf
drwxr-sr-x 6 root root 4096 Sep 7 08:45 db
-r--r--r-- 1 root root 2 Sep 7 08:45 format
drwxr-xr-x 2 root root 4096 Sep 7 08:45 hooks
drwxr-xr-x 2 root root 4096 Sep 7 08:45 locks
-rw-r--r-- 1 root root 229 Sep 7 08:45 README.txt
[root@nexus var]#
配置版本库
编辑版本库用户文件passwd,新增两个用户:admin和guest。
[users]
# harry = harryssecret
# sally = sallyssecret
admin = admin
guest = guest
编辑权限文件authz,用户admin设置可读写权限,guest设置只读权限。
编辑 /var/svn/svn-hello/conf/authz,末尾添加
[/]
admin = rw
guest = r
编辑svn服务综合配置文件 /var/svn/svn-hello/conf/svnserve.conf:添加以下配置
[general]
anon-access = none #控制非鉴权用户访问版本库的权限
auth-access = write #控制鉴权用户访问版本库的权限
password-db = passwd #指定用户名口令文件名
authz-db = authz #指定权限配置文件名
realm = svn-hello #指定版本库的认证域,即在登录时提示的认证域名称
svn自启和端口开放
启动服务设置开机自启
systemctl start svnserve.service
systemctl enable svnserve.service
安装net工具
yum install net-tools -y
通过netstat可以看到SVN打开了3690端口。
[root@nexus var]# netstat -tnlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:3690 0.0.0.0:* LISTEN 5332/svnserve
开放3609端口和telnet服务
[root@nexus var]# firewall-cmd --permanent --add-service=telnet
success
[root@nexus var]# firewall-cmd --permanent --add-port=3690/tcp
success
[root@nexus var]# firewall-cmd --reload
success