• linux svn服务器svnserve 安装配置


    svnserve 是一个轻量级的服务, 使用自定义的协议通过TCP/IP与客户端通讯。客户端通过由 svn:// 或者 svn+ssh:// 开始的URL访问svnserve服务器。

    svn服务器有两种运行方式:独立服务器svnserve和借助apache作为apache的一个模块,以webdav/deltav协议通讯。
    svn存储版本数据有两种方式:BDB和FSFS。BDB方式在服务器中断时,可能锁住数据。FSFS方式更安全些,兼容性好。
    一.安装subversion

    apt-get install subversion

    二.建立库文件
    1.创建文件夹

    2.创建版本库并指定数据存储模式为FSFS

    svnadmin  create --fs-type fsfs /root/svn/my/

    用户管理

    在版本库目录 /root/svn/my 有如下文件夹:

    conf  db  format  hooks  locks  README.txt

    conf文件夹有如下文件:

    authz  hooks-env.tmpl  passwd  svnserve.conf

     svnserver.conf配置示例:


    [general]

    anon-access=none  

    auth-access=write

    authz-db = authz
    password-db=passwd

    passwd配置:

    [users] //不可省略
    username1=password1
    username2=password2 //每个用户一行

    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


    group1=user1

    [repository:/root/svn/my]
    user1=rw


    [/]
    user1=rw

      svnserve -h
    usage: svnserve [-d | -i | -t | -X] [options]

    Valid options:
    -d [--daemon] : daemon mode
    -i [--inetd] : inetd mode
    -t [--tunnel] : tunnel mode
    -X [--listen-once] : listen-once mode (useful for debugging)
    -r [--root] ARG : root of directory to serve
    -R [--read-only] : force read only, overriding repository config file
    --config-file ARG : read configuration from file ARG
    --listen-port ARG : listen port. The default port is 3690.
    [mode: daemon, listen-once]
    --listen-host ARG : listen hostname or IP address
    By default svnserve listens on all addresses.
    [mode: daemon, listen-once]
    -6 [--prefer-ipv6] : prefer IPv6 when resolving the listen hostname
    [IPv4 is preferred by default. Using IPv4 and IPv6
    at the same time is not supported in daemon mode.
    Use inetd mode or tunnel mode if you need this.]
    -c [--compression] ARG : compression level to use for network transmissions
    [0 .. no compression, 5 .. default,

    通常启动SVN服务,仅指定SVN版本库的根目录,如下:

    1. svnserve -d -r /data/svn  

    然后在/data/svn下创建多个版本库:

    1. cd /data/svn  
    2. svnadmin create repos1  
    3. svnadmin create repos2  

    再依次配置repos1和repos2等版本库下的conf/svnserve.conf、conf/passwd、conf/authz文件。

    问题便来了,因为大多数的时候,同一个用户需要用相同的帐号和密码去访问不同的版本库,这时的权限配置就不好处理了,以前看其他人的解决方法是在svnserve.conf中指定passwd和authz的路径时用相对路径指到同一个文件。这是一个可行的方法,但新增版本库的时候,就得更改svnserve.conf文件,不方便。

    仔细看svnserve的帮助信息,大家都会发现有一个--config-file参数,这个参数就是用来指定svnserve.conf路径的,说到这,问题已经明了,只要在启动SVN服务的时候,指定--config-file参数,只要指定了此参数,所有的权限都由参数指定的svnserve.conf控制,而每个版本库conf目录下的svnserve.conf的配置都会忽略掉。

    1. svnserve -d -r /data/svn --config-file /data/svn/svnserve.conf  

    我登陆时报错:

    svn: E170001: Authorization failed

    找到一篇帖子:http://bbs.csdn.net/topics/310115750

    问题解决:
    http://hi.baidu.com/tianfu_xue/blog/item/9dbfd6fa4d416d839f51462b.html

    出现该问题基本都是三个配置文件的问题,下面把这个文件列出来。

    svnserve.conf:
    [general]
    anon-access = read
    auth-access = write
    password-db = passwd
    authz-db = authz

    passwd:
    [users]
    harry = harryssecret

    authz:
    [groups]
    [/]
    harry = rw

    出现authorization failed异常,一般都是authz文件里,用户组或者用户权限没有配置好,只要设置[/]就可以,代表根目录下所有的资源,如果要限定资源,可以加上子目录即可。

    http://www.ttlsa.com/svn/install-svnserve-on-linux/

  • 相关阅读:
    JavaScript闭包
    模块模式——方法
    产品与技术
    读书笔记
    屌丝求职记
    正则表达式regex狂记
    css狂记
    html狂记
    Android狂记忆
    关于调式
  • 原文地址:https://www.cnblogs.com/youxin/p/5513089.html
Copyright © 2020-2023  润新知