Centos7配置SVN服务端

环境

Centos 7

SVN 1.7

安装SVN

Shell> yum install subversion -y

准备配置和仓库

Shell> mkdir -p /mydata/repository /etc/svnserve
Shell> cd /mydata/repository
Shell> svnadmin create project1  #创建一个项目库
Shell> cp project1/conf/* /etc/svnserve/  #利用自动生成的模板作为svn服务端的配置基础

修改总体配置文件 /etc/svnserve/svnserve.conf

[general]
anon-access = none    #禁止匿名访问
auth-access = write   #登录用户可以有写权限
password-db = passwd  #用户名密码的配置文件
authz-db = authz    #用户权限的配置文件
realm = My Repository  #仓库的说明文本

修改用户的配置文件 /etc/svnserve/passwd

[users]
user1 = 111
user2 = 222

修改权限的配置文件 /etc/svnserve/authz

[groups]
admin = user1,user2  #用户组,建议所有用户都配置到组以方便权限管理

[/]            #根目录下所有用户都没有权限
* =

[/project1]       #project1项目,admin组的用户有读写权限,其他用户只读权限
@admin = rw
* = r

配置svnserve服务

查看下服务的信息

Shell> systemctl status svnserve
● svnserve.service - Subversion protocol daemon
   Loaded: loaded (/usr/lib/systemd/system/svnserve.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

下面是服务配置文件/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

OPTIONS="-r /mydata/repository --config-file /etc/svnserve/svnserve.conf"

默认端口是3690,若需要修改可以在OPTIONS中加上 --listen-port [port]

启动并配置开机自启

Shell> systemctl start svnserve
Shell> systemctl enable svnserve

测试使用

第一次输入用户名密码后会提示保存,以后就不需要再输入了

若不想保存更不想总提示保存,那就每个svn命令都加上这三个参数:--username user1 --password 111 --no-auth-cache

Shell> svn co svn://127.0.0.1/project1 ./project1
Shell> cd project1/
Shell> touch 1.txt
Shell> svn add 1.txt
Shell> svn ci . -m 'add 1.txt'
Shell> echo 111 >> 1.txt
Shell> svn ci . -m '修改 1.txt'
Shell> svn log 1.txt
  ------------------------------------------------------------------------
  r2 | user1 | 2019-03-18 17:26:22 +0800 (一, 2019-03-18) | 1 行
  
  修改 1.txt
  ------------------------------------------------------------------------
  r1 | user1 | 2019-03-18 17:25:19 +0800 (一, 2019-03-18) | 1 行
  
  add 1.txt
  ------------------------------------------------------------------------

over

猜你喜欢

转载自www.cnblogs.com/toSeek/p/10553530.html