CentOS 8.0 搭建SVN服务
CentOS 8.0系统的安装见文章《CentOS 8.0 图形化安装》
CentOS 8.0系统的基本配置见文章《CentOS 8.0 基本配置》
CentOS 8.0系统创建LVM分区见文章《CentOS 8.0 创建LVM分区》
1. 安装SVN
[root@Server ~]# yum -y install subversion //使用YUM安装SVN
Last metadata expiration check: 0:17:56 ago on Wed 25 Sep 2019 04:49:06 PM CST.
Dependencies resolved.
(中间省略……)
Verifying : apr-util-openssl-1.6.1-6.el8.x86_64 4/8
Verifying : libserf-1.3.9-8.module_el8.0.0+45+75bba4f4.x86_64 5/8
Verifying : subversion-1.10.2-1.module_el8.0.0+45+75bba4f4.x86_64 6/8
Verifying : subversion-libs-1.10.2-1.module_el8.0.0+45+75bba4f4.x86_64 7/8
Verifying : utf8proc-2.1.1-4.module_el8.0.0+45+75bba4f4.x86_64 8/8
Installed:
subversion-1.10.2-1.module_el8.0.0+45+75bba4f4.x86_64 apr-util-bdb-1.6.1-6.el8.x86_64 apr-util-openssl-1.6.1-6.el8.x86_64 apr-1.6.3-9.el8.x86_64 apr-util-1.6.1-6.el8.x86_64
libserf-1.3.9-8.module_el8.0.0+45+75bba4f4.x86_64 subversion-libs-1.10.2-1.module_el8.0.0+45+75bba4f4.x86_64 utf8proc-2.1.1-4.module_el8.0.0+45+75bba4f4.x86_64
Complete!
2. 创建SVN库
[root@Server ~]# mkdir /Data/Svn //创建SVN目录
[root@Server ~]# svnserve -d -r /Data/Svn
[root@Server ~]# svnadmin create /Data/Svn/01-ProductManagement
[root@Server ~]# svnadmin create /Data/Svn/02-ProductPrototype
[root@Server ~]# svnadmin create /Data/Svn/03-AxureTeamProject
[root@Server ~]# ls /Data/Svn/
01-ProductManagement 02-ProductPrototype 03-AxureTeamProject
[root@Server ~]# ls /Data/Svn/01-ProductManagement/
conf db format hooks locks README.txt
3. 配置SVN
[root@Server ~]# mkdir /Data/Svn/Conf
[root@Server ~]# cp /Data/Svn/01-ProductManagement/conf/* /Data/Svn/Conf/
[root@Server ~]# cd /Data/Svn/Conf/
[root@Server Conf]# ls
authz passwd svnserve.conf
[root@Server Conf]# vi 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
SuperAdmin = admin
Jacky.xi = admin,jacky.xi
# [/foo/bar]
# harry = rw
# &joe = r
# * =
# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
[01-ProductManagement:/]
@SuperAdmin = rw
[02-ProductPrototype:/]
@SuperAdmin = rw
[03-AxureTeamProject:/]
@SuperAdmin = rw
[root@Server conf]# vi passwd
### 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 = 1qaz@WSX
jacky.xi = jacky888
[root@Server Conf]# vi svnserve.conf
### This file controls the configuration of the svnserve daemon, if you
### use it to allow access to this repository. (If you only allow
### access through http: and/or file: URLs, then this file is
### irrelevant.)
### Visit http://subversion.apache.org/ for more information.
[general]
### The anon-access and auth-access options control access to the
### repository for unauthenticated (a.k.a. anonymous) users and
### authenticated users, respectively.
### Valid values are "write", "read", and "none".
### Setting the value to "none" prohibits both reading and writing;
### "read" allows read-only access, and "write" allows complete
### read/write access to the repository.
### The sample settings below are the defaults and specify that anonymous
### users have read-only access to the repository, while authenticated
### users have read and write access to the repository.
anon-access = none
auth-access = write
### The password-db option controls the location of the password
### database file. Unless you specify a path starting with a /,
### the file's location is relative to the directory containing
### this configuration file.
### If SASL is enabled (see below), this file will NOT be used.
### Uncomment the line below to use the default password file.
password-db = /Data/Svn/Conf/passwd
### The authz-db option controls the location of the authorization
### rules for path-based access control. Unless you specify a path
### starting with a /, the file's location is relative to the
### directory containing this file. The specified path may be a
### repository relative URL (^/) or an absolute file:// URL to a text
### file in a Subversion repository. If you don't specify an authz-db,
### no path-based access control is done.
### Uncomment the line below to use the default authorization file.
authz-db = /Data/Svn/Conf/authz
### The groups-db option controls the location of the file with the
### group definitions and allows maintaining groups separately from the
### authorization rules. The groups-db file is of the same format as the
### authz-db file and should contain a single [groups] section with the
### group definitions. If the option is enabled, the authz-db file cannot
### contain a [groups] section. Unless you specify a path starting with
### a /, the file's location is relative to the directory containing this
### file. The specified path may be a repository relative URL (^/) or an
### absolute file:// URL to a text file in a Subversion repository.
### This option is not being used by default.
# groups-db = groups
### This option specifies the authentication realm of the repository.
### If two repositories have the same authentication realm, they should
### have the same password database, and vice versa. The default realm
### is repository's uuid.
realm = Svn
### The force-username-case option causes svnserve to case-normalize
### usernames before comparing them against the authorization rules in the
### authz-db file configured above. Valid values are "upper" (to upper-
### case the usernames), "lower" (to lowercase the usernames), and
### "none" (to compare usernames as-is without case conversion, which
### is the default behavior).
# force-username-case = none
### The hooks-env options specifies a path to the hook script environment
### configuration file. This option overrides the per-repository default
### and can be used to configure the hook script environment for multiple
### repositories in a single file, if an absolute path is specified.
### Unless you specify an absolute path, the file's location is relative
### to the directory containing this file.
# hooks-env = hooks-env
[sasl]
### This option specifies whether you want to use the Cyrus SASL
### library for authentication. Default is false.
### Enabling this option requires svnserve to have been built with Cyrus
### SASL support; to check, run 'svnserve --version' and look for a line
### reading 'Cyrus SASL authentication is available.'
# use-sasl = true
### These options specify the desired strength of the security layer
### that you want SASL to provide. 0 means no encryption, 1 means
### integrity-checking only, values larger than 1 are correlated
### to the effective key length for encryption (e.g. 128 means 128-bit
### encryption). The values below are the defaults.
# min-encryption = 0
# max-encryption = 256
[root@Server Conf]# cp svnserve.conf /Data/Svn/01-ProductManagement/conf/
cp: overwrite '/Data/Svn/01-ProductManagement/conf/svnserve.conf'? y
[root@Server Conf]# cp svnserve.conf /Data/Svn/02-ProductPrototype/conf/
cp: overwrite '/Data/Svn/02-ProductPrototype/conf/svnserve.conf'? y
[root@Server Conf]# cp svnserve.conf /Data/Svn/03-AxureTeamProject/conf/
cp: overwrite '/Data/Svn/03-AxureTeamProject/conf/svnserve.conf'? y
4. 启动SVN服务
[root@Server Conf]# vi /usr/lib/systemd/system/svnserve.service //创建svnserve.service服务
[Unit]
Description=Subversion protocol daemon
After=syslog.target network.target
Documentation=man:svnserve(8)
[Service]
Type=forking
EnvironmentFile=/etc/sysconfig/svnserve
#ExecStart=/usr/bin/svnserve --daemon --pid-file=/run/svnserve/svnserve.pid $OPTIONS
ExecStart=/usr/bin/svnserve --daemon $OPTIONS
PrivateTmp=yes
[Install]
WantedBy=multi-user.target
[root@Server Conf]# systemctl daemon-reload
[root@Server Conf]# vi /etc/sysconfig/svnserve
# OPTIONS is used to pass command-line arguments to svnserve.
#
# Specify the repository location in -r parameter:
OPTIONS="-r /Data/Svn"
[root@Server Conf]# systemctl status svnserve.service //查看SVN服务状态
● svnserve.service - Subversion protocol daemon
Loaded: loaded (/usr/lib/systemd/system/svnserve.service; disabled; vendor preset: disabled)
Active: inactive (dead)
Docs: man:svnserve(8)
[root@Server Conf]# systemctl start svnserve.service //启动SVN服务
[root@Server Conf]# systemctl enable svnserve.service //设置SVN服务开机自启动
Created symlink /etc/systemd/system/multi-user.target.wants/svnserve.service → /usr/lib/systemd/system/svnserve.service.
5. 安装SVN客户端(Windows版)
1、下载TortoiseSVN安装包及语言包
链接:https://pan.baidu.com/s/1A52eiAgLsf4MsLUhPb9Btw
提取码:nso4
2、安装TortoiseSVN
3、安装简体中文语言包
6. 检出SVN库
1、如图-11所示,在“D:\全栈POT\Svn”目录下的空白处点击鼠标右键,点击“SVN 检出(K)...”。
2、如图-12所示,在“检出”界面中填入“版本库URL”和“检出至目录”,版本库URL为“svn://172.29.1.190/01-ProductManagement”,检出至目录为“D:\全栈POT\Svn\01-产品管理”,点击“确定”。
3、如图-13所示,认证用户权限,填入“用户名”和“密码”,用户名为“admin”,密码为“1qaz@WSX”,并勾选“保存认证”,点击“确定”。
4、如图-14所示,检出成功,当前版本为0,点击“确定”。
5、如图-15所示,在“D:\全栈POT\Svn”目录下已经存在从SVN库检出的“01-产品管理”目录。
6、如图-16所示,检出“02-ProductPrototype”,在“检出”界面中填入“版本库URL”和“检出至目录”,版本库URL为“svn://172.29.1.190/02-ProductPrototype”,检出至目录为“D:\全栈POT\Svn\02-产品原型HTML”,点击“确定”。
7、如图-17所示,检出“03-AxureTeamProject”,在“检出”界面中填入“版本库URL”和“检出至目录”,版本库URL为“svn://172.29.1.190/03-AxureTeamProject”,检出至目录为“D:\全栈POT\Svn\03-Axure团队项目”,点击“确定”。
8、如图-18所示,“01-ProductManagement”、“02-ProductPrototype”和“03-AxureTeamProject”均已被成功检出,分别对应“01-产品管理”、“02-产品原型HTML”和“03-Axure团队项目”。
9、在“01-产品管理”目录下创建目录“01-PersonalFolder”以及在“01-PersonalFolder”目录下创建目录“01-Jacky.xi”,如图-19所示。
10、如图-20所示,在“01-产品管理”目录下的空白处点击鼠标右键,点击“SVN 提交(C)...”。
11、如图-21所示,在变更列表中选中需要提交的文件或文件夹,点击“确定”。
12、如图-22所示,提交成功,当前版本为1,点击“确定”。
13、如图-23所示,目录“01-PersonalFolder”及其子目录“01-Jacky.xi”已提交成功。
14、在“02-产品原型HTML”目录下创建目录“01-Jacky.xi”,并执行“SVN提交(C)...”,如图-24所示,在变更列表中选中需要提交的文件或文件夹,点击“确定”并提交成功。
15、在“03-Axure团队项目”目录下创建目录“01-Jacky.xi”,并执行“SVN提交(C)...”,如图-25所示,在变更列表中选中需要提交的文件或文件夹,点击“确定”并提交成功。
7. 更新SVN权限配置
[root@Server Conf]# vi 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
SuperAdmin = admin
Jacky.xi = admin,jacky.xi
# [/foo/bar]
# harry = rw
# &joe = r
# * =
# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
[01-ProductManagement:/]
@SuperAdmin = rw
[01-ProductManagement:/01-PersonalFolder/01-Jacky.xi]
@Jacky.xi = rw
[02-ProductPrototype:/]
@SuperAdmin = rw
[02-ProductPrototype:/01-Jacky.xi]
@Jacky.xi = rw
[03-AxureTeamProject:/]
@SuperAdmin = rw
[03-AxureTeamProject:/01-Jacky.xi]
@Jacky.xi = rw
8. 用户Jacky.xi检出。
1、如图-26所示,在“D:\全栈POT\Svn-Jacky.xi”目录下的空白处点击鼠标右键,点击“SVN 检出(K)...”。
2、如图-27所示,在“检出”界面中填入“版本库URL”和“检出至目录”,版本库URL为“svn://172.29.1.190/01-ProductManagement/01-PersonalFolder/01-Jacky.xi”,检出至目录为“D:\全栈POT\Svn-Jacky.xi\01-产品管理\01-个人目录\01-Jacky.xi”,点击“确定”。
3、如图-28所示,认证用户权限,填入“用户名”和“密码”,用户名为“jacky.xi”,密码为“jacky888”,并勾选“保存认证”,点击“确定”。
4、如图-29所示,检出成功,当前版本为1,点击“确定”。
5、如图-30所示,Jacky.xi已成功检出“svn://172.29.1.190/01-ProductManagement/01-PersonalFolder/01-Jacky.xi”。
6、如图-31所示,检出“02-ProductPrototype\01-Jacky.xi”,在“检出”界面中填入“版本库URL”和“检出至目录”,版本库URL为“svn://172.29.1.190/02-ProductPrototype/01-Jacky.xi”,检出至目录为“D:\全栈POT\Svn-Jacky.xi\02-产品原型HTML\01-Jacky.xi”,点击“确定”。
7、如图-32所示,检出“03-AxureTeamProject\01-Jacky.xi”,在“检出”界面中填入“版本库URL”和“检出至目录”,版本库URL为“svn://172.29.1.190/03-AxureTeamProject/01-Jacky.xi”,检出至目录为“D:\全栈POT\Svn-Jacky.xi\03-Axure团队项目\01-Jacky.xi”,点击“确定”。
8、如图-33所示,“01-ProductManagement\01-PersonalFolder\01-Jacky.xi”、“02-ProductPrototype\01-Jacky.xi”和“03-AxureTeamProject\01-Jacky.xi”均已被成功检出,分别对应“01-产品管理\01-个人目录\01-Jacky.xi”、“02-产品原型HTML\01-Jacky.xi”和“03-Axure团队项目\01-Jacky.xi”。