• linux系统Centos环境下搭建SVN服务器及权限配置


    linux系统Centos环境下如何搭建SVN服务器以及svnserve.conf、authz、passwd配置文件详细介绍

     

    1
    至于svn的概念,这里就不做详细阐述了,可以自行百度。简单来讲就是一个代码管理工具。本笔记就是记录下svn安装搭建步骤而已。
    1,yum安装svn

    1. yum install subversion -y

    2.验证是否安装完成

    1. svnserve --version

    如显示svn版本以及介绍信息,说明svn安装成功。或直接netstat 或ps查看也可以。

    3,创建svn版本库
    mkdir /home/svn   #把版本库放在了home目录下的svn文件夹
    svnadmin create /home/svn/repo0 #将svn作为所有版本库的目录,并创建了一个名为repo0的版本库

    4.配置当前的版本库
    创建版本库后,在当前版本库目录中会生成下面的文件,重点是配置文件。

    1. [root@yueminghai svn]# cd /home/svn/repo0
    2. [root@yueminghai repo0]# ll
    3. 总用量 24
    4. drwxr-xr-x 2 root root 4096 5 5 05:50 conf
    5. drwxr-sr-x 6 root root 4096 5 5 05:50 db
    6. -r--r--r-- 1 root root 2 5 5 05:50 format
    7. drwxr-xr-x 2 root root 4096 5 5 05:50 hooks
    8. drwxr-xr-x 2 root root 4096 5 5 05:50 locks
    9. -rw-r--r-- 1 root root 229 5 5 05:50 README.txt
    10. [root@yueminghai repo0]# ll conf
    11. 总用量 12
    12. -rw-r--r-- 1 root root 1080 5 5 05:50 authz
    13. -rw-r--r-- 1 root root 309 5 5 05:50 passwd
    14. -rw-r--r-- 1 root root 2279 5 5 05:50 svnserve.conf
    15.  

    说明

    (1)svnserve.conf:  svn服务综合配置文件,只需要更改四行。
    (2)passwd: 用户名口令文件。前边是svn账号,后边是密码,密码是明文存储。配置哪些用户可以授权使用,里边包含用户名和密码。
    (3)authz: 权限配置文件。
    (4)注意更改svnserve.conf配置文件需要重启svn,更高authz和passwd不需要重启svn。重启方法:pkill svnserve 然后重新svnserve -d -r 项目目录即可。

    4.1 修改passwd文件

    1. ### This file is an example password file for svnserve.
    2. ### Its format is similar to that of svnserve.conf. As shown in the
    3. ### example below it contains one section labelled [users].
    4. ### The name and password for each user follow, one account per line.
    5.  
    6. [users]
    7. # harry = harryssecret
    8. # sally = sallyssecret
    9. zhangsan = 123456
    10. lisi = 123456

    前边是svn账号,后边是密码,密码是明文存储。配置哪些用户可以授权使用,里边包含用户名和密码。

    4.2修改authz文件。
    这个配置文件就两个地方需要设置就可以了,一个是组和用户的设置,另一个是版本库的目录格式配置以及权限分配。
    4.2.1,组和用户配置。
    (1)一个组group可以包含一个和多个用户,其中用户名必须在用户配置文件中已经定义。
    (2)可以将指定具体组,比如开发组和运维组等。
    4.2.2,版本库配置以及权限分配。
    版本库目录格式为  :
    [版本库:/项目/目录]
    用户名 = 权限
    @组名 = 权限
    说明:
    (1)权限,分为r,w,rw和空。空代表没有任何权限
    (2)版本库目录多种写法,如果只写根/代表对这个项目以及下边所有目录都有权限,如果单独制定目录,可以加上具体目录名。
    其中根是svn启动的时候我们指定的-r指定的版本库。
    举例如下:
    [repo0:/] 代表对repo0所有版本库设置权限权限
    [repo0:/yueminghai]  代表对repo0版本库下的yueminghai项目设置权限
    [repo0:/yueminghai/demo]  代表对repo0版本库下的yueminghai项目的demo目录设置权限

    1. [aliases]
    2. # joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average
    3. #这里实现了别名的定义
    4. [groups]
    5. # harry_and_sally = harry,sally
    6. # harry_sally_and_joe = harry,sally,&joe
    7. team0=zhangsan #将上面创建的分成两个组
    8. team1=lisi
    9. # [/foo/bar]
    10. # harry = rw
    11. # &joe = r #上面的别名定义在这里实现 &在这里理解为指针就很容易了
    12. # * =
    13. # [repository:/baz/fuz]
    14. # @harry_and_sally = rw
    15. # * = r
    16. [repo0:/]
    17. @team0=r
    18. @team1=rw
    19. yueminghai = r
    20. # 第一个小组只有读取的权限,第二个小组有读写的权限
    21. # 单个版本库的权限配置在这个文件中实现

    4.3 修改svnserve.conf并重启svn
    vi  svnserve.conf 主要修改如下参数,其他不需要修改:
    1. anon-access = none
    2. auth-access = write
    3. password-db = passwd  #这个文件可以统一指定一个passwd文件便于统一管理不需要单独每个版本库单独配置。
    4. authz-db = authz  #这个文件可以统一指定一个authz文件便于统一管理不需要单独每个版本库单独配置。
    1. [general]
    2. ### These options control access to the repository for unauthenticated
    3. ### and authenticated users.  Valid values are "write", "read",
    4. ### and "none".  The sample settings below are the defaults.
    5. anon-access = none #没有登录的用户不能访问
    6. auth-access = write #登录的用户可以写入
    7. ### The password-db option controls the location of the password
    8. ### database file.  Unless you specify a path starting with a /,
    9. ### the file's location is relative to the directory containing
    10. ### this configuration file.
    11. ### If SASL is enabled (see below), this file will NOT be used.
    12. ### Uncomment the line below to use the default password file.
    13. password-db = passwd #密码文件为当前目录下的passwd
    14. ### The authz-db option controls the location of the authorization
    15. ### rules for path-based access control.  Unless you specify a path
    16. ### starting with a /, the file's location is relative to the the
    17. ### directory containing this file.  If you don't specify an
    18. ### authz-db, no path-based access control is done.
    19. ### Uncomment the line below to use the default authorization file.
    20. authz-db = authz #验证文件为当前目录下的authz

    这里着重说明下,参数前面不要有空格,否则启动报错。
    5 导入、导出工程
    导入

    1. $ mkdir MyProject
    2. $ mkdir MyProject/hehe
    3. $ mkdir MyProject/haha
    4. svn import MyProject svn://192.168.1.112/repo0/MyProject -m "first import project"

    导出

    1. svn co svn://192.168.1.112/repo0/MyProject

    配置完毕。有问题或建议的朋友可以留言。

  • 相关阅读:
    Android热补丁动态修复
    Android用gif做启动页
    如果通过adb查看当前显示的activity
    Android网络框架比较
    Android高清巨图加载方案
    一些Windows下经验
    工作总结
    C++网络编程总结
    编写导出库
    GridCtrl控件的使用
  • 原文地址:https://www.cnblogs.com/yueminghai/p/7776896.html
Copyright © 2020-2023  润新知