一.安装svn 服务
yum install subversion
#查看版本
svnserve –version
二.创建版本库
假设根目录位于 /opt/svn
svnadmin create /opt/svn/project/
三.配置svn服务器
修改位于仓库根目录下
3.1配置用户名密码 passwd
### This file is an example password file for svnserve.
### Its format is similar to that of svnserve.conf. As shown in the
### example below it contains one section labelled [users].
### The name and password for each user follow, one account per line.
[users]
# harry = harryssecret
# sally = sallyssecret
admin=admin8899
3.2配置目录访问权限authz
cat authz
### This file is an example authorization file for svnserve.
### Its format is identical to that of mod_authz_svn authorization
### files.
### As shown below each section defines authorizations for the path and
### (optional) repository specified by the section name.
### The authorizations follow. An authorization line can refer to:
### - a single user,
### - a group of users defined in a special [groups] section,
### - an alias defined in a special [aliases] section,
### - all authenticated users, using the '$authenticated' token,
### - only anonymous users, using the '$anonymous' token,
### - anyone, using the '*' wildcard.
###
### A match can be inverted by prefixing the rule with '~'. Rules can
### grant read ('r') access, read-write ('rw') access, or no access
### ('').
[aliases]
# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average
[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe
# [/foo/bar]
# harry = rw
# &joe = r
# * =
# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
[/]
admin=rw
*=rw
也可以修改项目中子目录的访问权限,也可以基于分组进行管理权限
3.3整体配置 svnserve.conf
打开以下注释
anon-access = none #控制非鉴权用户访问版本库的权限
auth-access = write #控制鉴权用户访问版本库的权限
password-db = passwd #指定用户名口令文件名
authz-db = authz #指定权限配置文件名
#realm = spring-hello-world #指定版本库的认证域,即在登录时提示的认证域名称
3.4 防火墙问题
用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
四.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
svnserve -d -r /var/www/svn
五.出错解决
- svnserve.conf:12: Option expected 是因为subversion读取配置文件svnserve.conf时,无法识别有前置空格的配置文件
- Invalid authz configuration 原因是svn服务端authz文件配置不正确,我出现的错误是为不存在的用户组设置权限
- centos7 Can't open file 'db/txn-current-lock': Permission denied
主要有两种可能
1.目录权限:
chmod -R 775 /opt/svn
尝试提交svn,如果可以则结束,如果不行则继续往下
2.如果是linux的服务器需要关闭SElinux:
临时关闭下次重启后失效:setenforce 0
永久关闭:vi /etc/sysconfig/selinux #配置SELINUX=disable
参考链接
- CentOS 7下搭建配置SVN服务器
- svn精细配置各个目录的权限
-