前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >005-centos7 搭建svn服务器

005-centos7 搭建svn服务器

作者头像
上善若水.夏
发布2018-09-28 11:31:52
1.3K1
发布2018-09-28 11:31:52
举报
文章被收录于专栏:上善若水

一.安装svn 服务

代码语言:javascript
复制
yum install subversion
#查看版本
svnserve –version

二.创建版本库

假设根目录位于 /opt/svn

代码语言:javascript
复制
svnadmin create /opt/svn/project/ 

三.配置svn服务器

修改位于仓库根目录下

3.1配置用户名密码 passwd

代码语言:javascript
复制
### 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

代码语言:javascript
复制
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

打开以下注释

代码语言:javascript
复制
anon-access = none                     #控制非鉴权用户访问版本库的权限
auth-access = write                    #控制鉴权用户访问版本库的权限
password-db = passwd                   #指定用户名口令文件名
authz-db = authz                       #指定权限配置文件名
#realm = spring-hello-world             #指定版本库的认证域,即在登录时提示的认证域名称

3.4 防火墙问题

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

代码语言:javascript
复制
$ 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端口:

代码语言:javascript
复制
$ sudo firewall-cmd --permanent --add-service=telnet
$ sudo firewall-cmd --permanent --add-port=3690/tcp
$ sudo firewall-cmd --reload

四.SVN服务

启动SVN服务。

代码语言:javascript
复制
$ sudo systemctl start svnserve.service

检查服务是否启动成功。

代码语言:javascript
复制
$ 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端口。

代码语言:javascript
复制
$ 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 

设置成开机启动。

代码语言:javascript
复制
$ sudo systemctl enable svnserve.service

svnserve -d -r /var/www/svn

五.出错解决

  1. svnserve.conf:12: Option expected 是因为subversion读取配置文件svnserve.conf时,无法识别有前置空格的配置文件
  2. Invalid authz configuration 原因是svn服务端authz文件配置不正确,我出现的错误是为不存在的用户组设置权限
  3. 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

参考链接

  1. CentOS 7下搭建配置SVN服务器
  2. svn精细配置各个目录的权限
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2018.01.19 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 一.安装svn 服务
  • 二.创建版本库
  • 三.配置svn服务器
    • 3.1配置用户名密码 passwd
      • 3.2配置目录访问权限authz
        • 3.3整体配置 svnserve.conf
          • 3.4 防火墙问题
          • 四.SVN服务
            • 启动SVN服务。
              • 检查服务是否启动成功。
                • 设置成开机启动。
                • 五.出错解决
                • 参考链接
                领券
                问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档