linux上搭建svn服务器

还是拿我的廉价的腾讯云服务器来练手,O(∩_∩)O哈哈~

强调下,我的服务器是centos7.4,其他可能略有不同。下面开始~

1、安装Subversion

 首先查看是否已经装了svn服务器了,别白费功夫呀  

[root@VM_15_8_centos ~]# rpm -qa subversion
[root@VM_15_8_centos ~]# 

出现上面的情况是没安装!

 #卸载旧版

   如果已安装,可用如下命令卸载:  

[root@VM_15_8_centos ~]# yum remove subversion

   #安装

[root@VM_15_8_centos ~]# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql

  #确认是否安装成功

[root@VM_15_8_centos ~]# svnserve --version
svnserve, version 1.7.14 (r1542130)
   compiled Apr 11 2018, 02:40:28

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、创建代码库 

[root@VM_15_8_centos ~]# mkdir -p /xjy/svn/repositories
[root@VM_15_8_centos repositories]# svnadmin create /xjy/svn/repositories

执行上面的命令后,自动建立repositories库,查看/xjy/svn/repositories 
文件夹发现包含了conf, db,format,hooks, locks, README.txt等文件,说明一个SVN库已经建立。

subversion目录说明:

    • db目录:就是所有版本控制的数据存放文件
    • hooks目录:放置hook脚本文件的目录
    • locks目录:用来放置subversion见艰苦锁定数据的目录,用来追踪存取文件库的客户端
    • format文件:是一个文本文件,里面只放了一个整数。表示当前文件库配置的版本号
    • conf目录:是这个仓库的配置文件(仓库的用户访问账号、权限等)

3、添加用户

要添加SVN用户非常简单,只需在/opt/svn/repositories/conf/passwd文件添加一个形如“username=password”的条目就可以了。为了测试,我添加了如下内容:

[users]
# harry = harryssecret
# sally = sallyssecret
#
xjy = xjy
server_group = server_pw
client_group = client_pw
test_group = test_pw

4、用户权限控制 

在/xjy/svn/repositories/conf/authz文件

[groups]

在这里创建权限组并指定组内用户,中间用,分割

# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe
admin = zhangcy,liuzz,shenkun
user = yangxt,maym,lizh,dongyan

为权限组分配权限
[/]
@admin = rw
@user = rw
* =

r表示对该目录有读权限,w表示对该目录有写权限,rw表示对该目录有读写权限。

最后一行的* =表示,除了上面设置了权限的用户组之外,其他任何人都被禁止访问本目录。这个很重要,一定要加上!

5、修改svnserve.conf文件,让用户和策略配置升效.

进入文件后,取消下面这些注释

[general]
anon-access = none
auth-access = write
password-db = /opt/svn/repositories/conf/passwd
authz-db =/opt/svn/repositories/conf/authz

6、启动svn服务器

svnserve -d -r /xjy/svn/repositories/  或者指定端口号启动服务器 svnserve -d -r /xjy/svn/repos --listen-port 3391
svn默认监听3690端口

 

 

over!

猜你喜欢

转载自www.cnblogs.com/xujingyang/p/9199539.html