阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

CentOS 7下搭建配置SVN服务器

151次阅读
没有评论

共计 3824 个字符,预计需要花费 10 分钟才能阅读完成。

CentOS 7 下搭建配置 SVN 服务器

1. 安装

CentOS 通过 yum 安装 subversion。

$ sudo yum install subversion

 subversion 安装在 /bin 目录:

$ which svnserve
/bin/svnserve

检查一下 subversion 是否安装成功。

$ svnserve –version
svnserve, version 1.7.14 (r1542130)
  compiled Nov 20 2015, 19:25:09

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. 建立版本库

subversion 默认以 /var/svn 作为数据根目录,可以通过 /etc/sysconfig/svnserve 修改这个默认位置。

$ 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

$ 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。

$ cat /etc/sysconfig/svnserve
OPTIONS="-r /opt/svn"

使用 svnadmin 建立版本库 spring-hello-world。

$ sudo mkdir -p /opt/svn
$ sudo svnadmin create /opt/svn/spring-hello-world

$ ll /opt/svn/
drwxr-xr-x. 6 root root 80 Nov 10 14:42 spring-hello-world

$ ll /opt/svn/spring-hello-world/
drwxr-xr-x. 2 root root  51 Nov 10 14:42 conf
drwxr-sr-x. 6 root root 4096 Nov 10 14:42 db
-r–r–r–. 1 root root    2 Nov 10 14:42 format
drwxr-xr-x. 2 root root 4096 Nov 10 14:42 hooks
drwxr-xr-x. 2 root root  39 Nov 10 14:42 locks
-rw-r–r–. 1 root root  229 Nov 10 14:42 README.txt

3. 配置

编辑用户文件 passwd,新增两个用户:admin 和 guest。

$ cat /opt/svn/spring-hello-world/conf/passwd 
[users]
admin = admin
guest = guest

编辑权限文件 authz,用户 admin 设置可读写权限,guest 设置只读权限。

$ cat /opt/svn/spring-hello-world/conf/authz 
[/]
admin = rw
guest = r

编辑 svnserve.conf:

$ cat /opt/svn/spring-hello-world/conf/svnserve.conf 
[general]
anon-access = none                     #控制非鉴权用户访问版本库的权限
auth-access = write                    #控制鉴权用户访问版本库的权限
password-db = passwd                   #指定用户名口令文件名
authz-db = authz                       #指定权限配置文件名
realm = spring-hello-world             #指定版本库的认证域,即在登录时提示的认证域名称 

 4. SVN 服务

启动 SVN 服务。

$ sudo systemctl start svnserve.service

检查服务是否启动成功。

$ ps aux | grep svn
root      16349  0.0  0.1 162180   900 ?        Ss   15:01   0:00 /usr/bin/svnserve --daemon --pid-file=/run/svnserve/svnserve.pid -r /opt/svn

通过 netstat 可以看到 SVN 打开了 3690 端口。

$ sudo netstat -tnlp
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      16349/svnserve

设置成开机启动。

$ sudo systemctl enable svnserve.service

 5. 客户端测试

客户端可以通过 TortoriseSVN 测试。

CentOS 7 下搭建配置 SVN 服务器

这时候可能会防火墙问题。如果是防火墙问题,会提示无法连接。

CentOS 7 下搭建配置 SVN 服务器

客户端用 telnet 无法连接。

C:\Temp>telnet 192.168.12.59 360

用 systemctl 检查服务器的防火墙配置:

$ firewall-cmd --list-all
public (default, active)
  interfaces: eno16777736 eno33554984
  sources: 
  services: dhcpv6-client ssh
  ports: 
  masquerade: no
  forward-ports: 
  icmp-blocks: 
  rich rules:

可以看到,没有 telnet 服务和 3690 端口。增加 telnet 服务器和 3690 端口:

$ sudo firewall-cmd --permanent --add-service=telnet
$ sudo firewall-cmd --permanent --add-port=3690/tcp
$ sudo firewall-cmd --reload

客户端再用 telnet,应该就可以了。

CentOS 7 下搭建配置 SVN 服务器

Ubuntu 14.04 下搭建 SVN 服务器 SVN://  http://www.linuxidc.com/Linux/2015-01/111956.htm

CentOS 7 下安装 iF.svnadmin 实现 Web 方式管理 SVN(源码安装)http://www.linuxidc.com/Linux/2016-08/134214.htm

CentOS7.2 编译安装 SVN1.9.5 客户端  http://www.linuxidc.com/Linux/2017-03/141387.htm

SVN 服务器搭建步骤及使用实战 http://www.linuxidc.com/Linux/2017-01/139282.htm

Windows 下 SVN 服务器搭建和使用 + 客户端重新设置密码 http://www.linuxidc.com/Linux/2013-05/85189p5.htm

CentOS 6.6 搭建 SVN 服务器 http://www.linuxidc.com/Linux/2016-12/137864.htm

CentOS 7.2 下 Nginx+MySQL+PHP-FPM+SVN 配置 Walle 自动化部署系统详解 http://www.linuxidc.com/Linux/2016-11/137703.htm

基于腾讯 CentOS 7 云服务器搭建 SVN 版本控制库  http://www.linuxidc.com/Linux/2017-05/144244.htm

CentOS 7.1 下 SVN 安装与配置 http://www.linuxidc.com/Linux/2016-12/138637.htm

CentOS 6.8 搭建 SVN(版本控制系统)及 SVN 的使用  http://www.linuxidc.com/Linux/2017-04/143093.htm

Subversion (SVN) 的详细介绍 :请点这里
Subversion (SVN) 的下载地址 :请点这里

本文永久更新链接地址 :http://www.linuxidc.com/Linux/2017-05/144254.htm

正文完
星哥说事-微信公众号
post-qrcode
 
星锅
版权声明:本站原创文章,由 星锅 2022-01-21发表,共计3824字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中