准备工作
参考:https://help.aliyun.com/zh/ecs/use-cases/deploying-and-using-svn?spm=a2c4g.11186623.0.0.29c27c9c3ZNkFd
创建用于部署SVN的ECS实例,具体操作,请参见自定义购买实例。
该实例必须满足以下条件:
实例已分配公网IP地址或绑定弹性公网IP(EIP)。
操作系统:Alibaba Cloud Linux 3、Alibaba Cloud Linux 2、CentOS 7.x。
实例规格:部署SVN服务所的实例规格与项目规格和团队规模有关,建议您使用4 vCPU、4 GiB以上的实例规格。
实例安全组的入方向规则已放行22、80、443端口。svnserve模式还需要放行3690端口。
部署SVN
运行以下命令,安装SVN
sudo yum install -y subversion
运行以下命令,查看SVN版本
svnserve --version
若显示以下内容则为正确安装
创建SVN库
依次运行以下命令,创建SVN版本库
sudo mkdir /var/svn #建立svn服务器根目录,各项目将存储于此
cd /var/svn
sudo svnadmin create /var/svn/svnrepos # 建立项目库目录,及svnrepos为项目名称,该项目所有内容将存储于此
依次运行以下命令,查看自动生成的版本库文件。
cd svnrepos
ls
配置SVN权限
参考:https://www.runoob.com/svn/svn-create-repo.html
设置项目库的账号密码
运行以下命令,打开用户配置文件
#在svnrepos目录下
cd conf/
sudo vim passwd
按i键进入编辑模式,移动光标至[users]下,添加用户账号和密码。添加账号和密码的格式为:账号 = 密码。例如,userTest(账号) = passWDTest(密码),如下图所示(注意等号两端要有一个空格)。
按Esc键退出编辑模式,并输入:wq保存并退出。
设置项目库账号的读写权限
运行以下命令,打开权限控制文件。
#在svnrepos/conf目录下
sudo vim authz
[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe
# 这个部分的格式是:
# 组 = 用户(如果有多个用户就用逗号隔开
user = user1, user2 # user这个组拥有两个用户
# 这个先不说 有点只可意会的感觉hhh
# [/foo/bar]
# harry = rw
# &joe = r
# * =
# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
# 这里格式是:
# [版本库名:路径]
# 如果针对组加权限就是 @组名 = 权限(r,w)
# 如果是针对个人就直接 用户 = 权限
# * = 的意思就是哪怕是没有设置,所有组都具备的权限
[repo:/] #repo这个版本库包括所有的文件
@user = r #user组拥有读权限
user1 = rw #user1这个用户拥有读写权限
* = #没设置的组无权限
设置项目库服务器配置
运行以下命令,打开SVN服务配置文件
sudo vim svnserve.conf
里面有很多内容,这里就显示一部分
anon-access:控制非鉴权用户访问版本库的权限(来自菜鸟驿站的术语)我的理解就是非用户能做的事(手动狗头; 填none应该就ok
auth-access:控制鉴权用户访问版本库的权限
password-db: 配置用户名密码的地方,默认的话就是当前文件夹下的passwd
authz-db: 配置用户权限的地方, 默认的话就是当前文件夹下的authz
### This file controls the configuration of the svnserve daemon, if you
### use it to allow access to this repository. (If you only allow
### access through http: and/or file: URLs, then this file is
### irrelevant.)
### Visit http://subversion.apache.org/ for more information.
[general]
### The anon-access and auth-access options control access to the
### repository for unauthenticated (a.k.a. anonymous) users and
### authenticated users, respectively.
### Valid values are "write", "read", and "none".
### Setting the value to "none" prohibits both reading and writing;
### "read" allows read-only access, and "write" allows complete
### read/write access to the repository.
### The sample settings below are the defaults and specify that anonymous
### users have read-only access to the repository, while authenticated
### users have read and write access to the repository.
anon-access = none
auth-access = write
### The password-db option controls the location of the password
### database file. Unless you specify a path starting with a /,
### the file's location is relative to the directory containing
### this configuration file.
### If SASL is enabled (see below), this file will NOT be used.
### Uncomment the line below to use the default password file.
password-db = passwd
........
authz-db = authz
启动服务
svnserve -d -r /var/svn --listen-port 3690 # 多库svnserve方式
ps -ef |grep svn # 查看SVN服务是否开启
killall svnserve # 命令可停止SVN服务
URL
svn://公网IP:3690/svnrepos