一、安装 SVN
1. 通过 yum 下载并安装
yum install subversion
[root@izbp11tfz245ne0doug99kz ~]# yum install subversion
2. 查看 SVN 版本
svnserve --version
[root@izbp11tfz245ne0doug99kz ~]# svnserve --version
3. 查看 SVN 安装目录
rpm -ql subversion
[root@izbp11tfz245ne0doug99kz ~]# rpm -ql subversion
二、SVN 版本库
1. 创建版本库目录
mkdir /var/svnrepos
为后面创建版本库提供存放位置。
[root@izbp11tfz245ne0doug99kz ~]# mkdir /var/svnrepos
2. 创建版本库
svnadmin create --fs-type fsfs /var/svnrepos/svn0
指定版本库存放的文件结构,有 fsfs 和 dbd,推荐使用 fsfs。
[root@izbp11tfz245ne0doug99kz ~]# svnadmin create --fs-type fsfs /var/svnrepos/svn0
3. 复制版本库配置文件到根目录
(1) 复制用户账户权限管理配置文件
cp /var/svnrepos/svn0/conf/authz /var/svnrepos/conf/
[root@izbp11tfz245ne0doug99kz ~]# cp /var/svnrepos/svn0/conf/authz /var/svnrepos/conf/
(2) 复制用户账号密码管理配置文件
cp /var/svnrepos/svn0/conf/passwd /var/svnrepos/conf/
[root@izbp11tfz245ne0doug99kz ~]# cp /var/svnrepos/svn0/conf/passwd /var/svnrepos/conf/
三、编辑版本库管理及配置文件
1. /var/svnrepos/conf/authz
用户账号权限管理。
修改内容:
[/]
USER1 = rw
USER2 = rw
完整配置文件内容:
### 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
[/]
USER1 = rw
USER2 = rw
2. /var/svnrepos/conf/passwd
用户账号密码管理。
修改内容:
USER1 = PASSWORD1
USER2 = PASSWORD2
完整配置文件内容:
### 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
USER1 = PASSWORD1
USER2 = PASSWORD2
3. /var/svnrepos/svn0/conf/svnserve.conf
配置文件。
修改内容:
anon-access = none
禁止匿名用户访问。
auth-access = write
授权用户拥有读写权限。
password-db = ../../conf/passwd
以相对路径指定用户账号密码管理文件。
authz-db = ../../conf/authz
以相对路径指定用户账号权限管理文件。
realm = My First Repository
指定认证域,默认为/var/svnrepos目录。
完整配置文件内容:
### 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 = read
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 = passwd
password-db = ../../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 the
### directory containing this file. 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 = authz
authz-db = ../../conf/authz
### 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 = My First Repository
### 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
[sasl]
### This option specifies whether you want to use the Cyrus SASL
### library for authentication. Default is false.
### This section will be ignored if svnserve is not 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
四、启动 SVN
方法2选1:
1. 使用 systemctl 命令启动
(1) 修改启动相关文件
/etc/sysconfig/svnserve
修改内容:
# OPTIONS="-r /var/svn"
OPTIONS="-r /var/svnrepos"
/var/svn 为默认 SVN 版本库根目录,如果不修改,使用 systemctl start svnserve.service 命令,系统将判断根目录不存在,无法启动。
完整配置文件内容:
# OPTIONS is used to pass command-line arguments to svnserve.
#
# Specify the repository location in -r parameter:
# OPTIONS="-r /var/svn"
OPTIONS="-r /var/svnrepos"
(2) 手动启动
systemctl start svnserve.service
[root@izbp11tfz245ne0doug99kz ~]# systemctl start svnserve.service
(3) 设置开机自启动
systemctl enable svnserve.service
[root@izbp11tfz245ne0doug99kz ~]# systemctl enable svnserve.service
Created symlink from /etc/systemd/system/multi-user.target.wants/svnserve.service to /usr/lib/systemd/system/svnserve.service.
2. 使用 svnserve 命令启动
(1) 手工启动
svnserve -d -r /var/svnrepos/
可以带上 --listen-port 参数指定端口号,默认为 3690。
[root@izbp11tfz245ne0doug99kz ~]# svnserve -d -r /var/svnrepos/
(2) 修改开机自启动文件
/etc/rc.local
修改内容:
svnserve -d -r /var/svnrepos/
完整配置文件内容:
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.
touch /var/lock/subsys/local
svnserve -d -r /var/svnrepos/
赋予 /etc/rc.d/rc.local 执行权限
chmod +x /etc/rc.d/rc.local
[root@izbp11tfz245ne0doug99kz ~]# chmod +x /etc/rc.d/rc.local
3. 查看进程状态
ps -aux | grep 'svnserve'
[root@izbp11tfz245ne0doug99kz ~]# ps -aux | grep 'svnserve'
root 13681 0.0 0.0 162196 436 ? Ss 21:00 0:00 svnserve -d -r /var/svnrepos/
root 13695 0.0 0.1 112656 2312 pts/2 S+ 21:01 0:00 grep --color=a uto svnserve
4. 查看进程端口
netstat -ln | grep 3690
[root@izbp11tfz245ne0doug99kz ~]# netstat -ln | grep 3690
tcp 0 0 0.0.0.0:3690 0.0.0.0:* LISTEN
五、访问 SVN
1. 下载客户端和中文语言包
SVN官网下载