在centos7下安装svn

Posted lewo的博客

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在centos7下安装svn相关的知识,希望对你有一定的参考价值。

SVN的安装

yum install subversion

服务端命令

1. svnserver - 控制svn系统服务的启动等

2. svnadmin - 版本库的创建/导出/导入/删除等

3. svnlook - 查看版本库的信息等

客户端命令

1. svn - 版本库的检出/更新/提交/重定向等

创建版本库

1. svnadmin create /www/version_test_1;

2. cd /www; svnadmin create version_test_2;

注意:如果 cd /www/version_test_1; svnadmin create version_test_2 会抛出异常(svnadmin: E165002: ‘/www/version_test_1/version_test_2‘ is a subdirectory of an existing repository rooted at ‘/www/version_test_1‘),故不能再已有版本库里面再次创建版本库。

3. 指定版本库数据保存类型: svnadmin create --fs-type fsfs(数据保存类型,还可以指定dbd) xxxx(版本库名称),如果想了解fsfs和dbd的区别可以自行百度,这里不过多阐述;推荐使用fsfs数据保存类型;

删除版本库

1. rm -rvf /www/version_test_1;使用linux自带的命令把整个版本库删除即可;

版本库配置

配置文件位于: /www/version_test_2/conf/

存在三个文件分别是:

  1. authz -- 配置用户组以及用户组权限

  2. passwd -- 配置用户名和密码

  3. svnserve.conf -- 配置默认权限、权限配置文件及密码配置文件

版本库权限分组

vim svnserve.conf :

 1 ### This file controls the configuration of the svnserve daemon, if you
 2 ### use it to allow access to this repository.  (If you only allow
 3 ### access through http: and/or file: URLs, then this file is
 4 ### irrelevant.)
 5 
 6 ### Visit http://subversion.apache.org/ for more information.
 7 
 8 [general]
 9 ### The anon-access and auth-access options control access to the
10 ### repository for unauthenticated (a.k.a. anonymous) users and
11 ### authenticated users, respectively.
12 ### Valid values are "write", "read", and "none".
13 ### Setting the value to "none" prohibits both reading and writing;
14 ### "read" allows read-only access, and "write" allows complete 
15 ### read/write access to the repository.
16 ### The sample settings below are the defaults and specify that anonymous
17 ### users have read-only access to the repository, while authenticated
18 ### users have read and write access to the repository.
19 # anon-access = read
20 # auth-access = write
21 ### The password-db option controls the location of the password
22 ### database file.  Unless you specify a path starting with a /,
23 ### the files location is relative to the directory containing
24 ### this configuration file.
25 ### If SASL is enabled (see below), this file will NOT be used.
26 ### Uncomment the line below to use the default password file.
27 # password-db = passwd
28 ### The authz-db option controls the location of the authorization
29 ### rules for path-based access control.  Unless you specify a path
30 ### starting with a /, the files location is relative to the the
31 
32 [general]
33 ### The anon-access and auth-access options control access to the
34 ### repository for unauthenticated (a.k.a. anonymous) users and
35 ### authenticated users, respectively.
36 ### Valid values are "write", "read", and "none".
37 ### Setting the value to "none" prohibits both reading and writing;
38 ### "read" allows read-only access, and "write" allows complete 
39 ### read/write access to the repository.
40 ### The sample settings below are the defaults and specify that anonymous
41 ### users have read-only access to the repository, while authenticated
42 ### users have read and write access to the repository.
43 # anon-access = read
44 # auth-access = write
45 ### The password-db option controls the location of the password
46 ### database file.  Unless you specify a path starting with a /,
47 ### the files location is relative to the directory containing
48 ### this configuration file.
49 ### If SASL is enabled (see below), this file will NOT be used.
50 ### Uncomment the line below to use the default password file.
51 # password-db = passwd
52 ### The authz-db option controls the location of the authorization
53 ### rules for path-based access control.  Unless you specify a path
54 ### starting with a /, the files location is relative to the the
55 ### directory containing this file.  If you dont specify an
56 ### authz-db, no path-based access control is done.
57 ### Uncomment the line below to use the default authorization file.
58 # authz-db = authz
59 ### This option specifies the authentication realm of the repository.
60 ### If two repositories have the same authentication realm, they should
61 ### have the same password database, and vice versa.  The default realm
62 ### is repositorys uuid.
63 # realm = My First Repository
64 ### The force-username-case option causes svnserve to case-normalize
65 ### usernames before comparing them against the authorization rules in the
66 ### authz-db file configured above.  Valid values are "upper" (to upper-
67 ### case the usernames), "lower" (to lowercase the usernames), and
68 ### "none" (to compare usernames as-is without case conversion, which
69 ### is the default behavior).
70 # force-username-case = none
71 
72 [sasl]
73 ### This option specifies whether you want to use the Cyrus SASL
74 ### library for authentication. Default is false.
75 ### This section will be ignored if svnserve is not built with Cyrus
76 ### SASL support; to check, run svnserve --version and look for a line
77 ### reading Cyrus SASL authentication is available.
78 # use-sasl = true
79 ### These options specify the desired strength of the security layer
80 ### that you want SASL to provide. 0 means no encryption, 1 means
81 ### integrity-checking only, values larger than 1 are correlated
82 ### to the effective key length for encryption (e.g. 128 means 128-bit
83 ### encryption). The values below are the defaults.
84 # min-encryption = 0
85 # max-encryption = 256

在19行: anon-access = read || write || none,表示没有用户名和密码的用户访问该版本库怎么操作

在20行: auth-access = write || read || none,表示通过用户名和密码的用户访问该版本库怎么操作

上述 read、write 、none 意思:

1. read 指允许更新代码

2. write 指允许更新代码,也允许提交代码

3. none 指什么都干不了

在27行: password-db = passwd,表示指定用户名和密码的文件路径(既支持相对路径,又支持绝对路径)

在58行: authz-db = authz,表示指定权限分组的文件路径(既支持相对路径,又支持绝对路径)

最终将svnserve.conf文件修改为:

anon-access = none

auth-access = write

password-db = passwd

authz-db = authz

:wq 保存退出即可。

vim 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

在7、8行已经给出了用户和密码的格式,则现只需要在9行添加:

jiangbo = 123456

随后再可以添加其他人来操作该版本库:

zhangsan = 123456
lisi = 123456
wangwu = 123456

:wq 保存退出即可。

vim authz:

 1 ### This file is an example authorization file for svnserve.
 2 ### Its format is identical to that of mod_authz_svn authorization
 3 ### files.
 4 ### As shown below each section defines authorizations for the path and
 5 ### (optional) repository specified by the section name.
 6 ### The authorizations follow. An authorization line can refer to:
 7 ###  - a single user,
 8 ###  - a group of users defined in a special [groups] section,
 9 ###  - an alias defined in a special [aliases] section,
10 ###  - all authenticated users, using the $authenticated token,
11 ###  - only anonymous users, using the $anonymous token,
12 ###  - anyone, using the * wildcard.
13 ###
14 ### A match can be inverted by prefixing the rule with ~. Rules can
15 ### grant read (r) access, read-write (rw) access, or no access
16 ### (‘‘).
17 
18 [aliases]
19 # joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average
20 
21 [groups]
22 # harry_and_sally = harry,sally
23 # harry_sally_and_joe = harry,sally,&joe
24 
25 # [/foo/bar]
26 # harry = rw
27 # &joe = r
28 # * =
29 
30 # [repository:/baz/fuz]
31 # @harry_and_sally = rw
32 # * = r

在18行:别名配置

在21行:用户组配置,格式是(组名 = 用户1,用户2,...,用户n)

示例:

[groups]
# 产品经理组
pm = jiangbo
# 开发人员组
dev = zhangsan,wangwu
# 菜鸟组
rookie = lisi

在25行:表示版本库的目录,例如 [/] 表示版本库的根目录,[/foo/bar] 表示版本库根目录下的 foo 文件夹下面的 bar 文件夹

示例:

[/]
# 表示项目径路组有更新和提交的权限
@pm = rw
# 表示开发组只有更新的权限
@dev = r
# 表示 李四 这个用户自由更新的权限
lisi = r

在30行:表示repository版本库下目录,例如 [repository:/] 表示repository版本库的根目录,[repository:/baz/fuz] 表示repository版本库目录下的 baz 文件夹下面的 fuz 文件夹

示例:

[version_test_n:/]
# 表示该版本库下面所有用户都有更新和提交的权限
* = rw

:wq 保存退出即可。

版本库的访问

服务端和客户端的关系(svn服务端 :svn客户端 = 1 : n )

运行svn服务端: svnserve -d -r /www/version_test_2/ ,如果没有什么异常消息则证明svn服务端运行成功!

个人定义的版本库的访问两种形式:

  1. 命令行的形式访问

    $ mkdir svntest

    $ cd svntest

    /svntest$ svn checkout(co) svn://192.168.0.104 (--username jiangbo --password 123456)

  2. 图像界面的形式访问

    下载tortoisesvn进行svn检出

SVN服务自启动

vim /etc/rc.local:

 1 #!/bin/bash
 2 # THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
 3 #
 4 # It is highly advisable to create own systemd services or udev rules
 5 # to run scripts during boot instead of using this file.
 6 #
 7 # In contrast to previous versions due to parallel execution during boot
 8 # this script will NOT be run after all other services.
 9 #
10 # Please note that you must run chmod +x /etc/rc.d/rc.local to ensure
11 # that this script will be executed during boot.
12 
13 touch /var/lock/subsys/local

在13行下面加上 svn 服务自启动:

svnserve -d -r /www/version_test_2/

ok!后续会将基础操作写入博客,敬请期待!!

以上是关于在centos7下安装svn的主要内容,如果未能解决你的问题,请参考以下文章

在centos7下安装svn

[转]CentOS7 下安装svn

centos7下通过yum安装svn怎么删除

centOS7下SVN的安装和使用

CentOS7下SVN server的安装与配置

centos7.5 SVN 搭建