部署
安装
yum install subversion
查看版本
svnserve --version
创建版本库
svnadmin create /data/svn/repo
配置svn信息
进入版本库中的配置目录conf,此目录有三个文件: svn服务综合配置文件(svnserve.conf)、 用户名口令文件(passwd)、权限配置文件(authz)
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 = 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
### 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
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
[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
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]
admin = admin
janlyn = janlyn
janlyn01 = janlyn01
janlyn02 = janlyn02
# 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
#
[/]
@admin = rw
[repo:/janlyn]
@janlyn = rw
[repo:/janlyn01]
@janlyn01 = rw
[repo:/janlyn02]
@janlyn02 = rw
[repo:/janlyn/python]
@janlyn01 = r
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
启用
svnserve -d -r /data/svn/
连接路径
svn://ip/repo
http配置
安装apache
yum install httpd
修改apache默认端口
vim /etc/httpd/conf/httpd.conf
启动apache
systemctl start httpd.service
测试,访问下面连接,出现apache主页
http://IP:8088
默认html目录
var/www/html
安装mod_dav_svn
yum install mod_dav_svn
编辑subversion.conf
vim /etc/httpd/conf.d/subversion.conf
<Location /svn>
DAV svn
SVNParentPath /data/svn
SVNListParentPath on
AuthType Basic
AuthName "SVN By Janlyn"
AuthzSVNAccessFile /data/svn/conf/authz
AuthUserFile /data/svn/conf/http_passwd
Require valid-user
</Location>
htpasswd -bc http_passwd janlyn janlyn123 #创建http_passwd文件,并添加用户janlyn,密码为janlyn123
再次添加用户时
htpasswd -n http_passwd janlyn01 janlyn456 #把用户janlyn01密码janlyn456添加到已存在的密码文件(http_passwd)中
修改svn目录属组与属主为apache,方便http访问
chown -R apache.apache /data/svn
报错
SVN Commit的时候提示Unexpected HTTP status 413 ‘Request Entity Too Large’ on xxxx
在nginx的conf.d里配置的conf文件增加:
client_max_body_size 1024M;
大小可以自己根据上传文件大小来定义
备份&迁移
将原来的Repository导出为一个文件
svnadmin dump /data/svn/repo > /data/repo.dump
/data/svn/repo是svn库存放的地址.
在新服务器上配置相同svn环境,如
svnadmin create /svn/repo
将repos导入新库中
svnadmin load /data/svn/repo < /data/repo.dump
将原服务器的配置文件复制到新服务器,如authz,passwd,svnserve.conf
启动新svn
svnserve -d --listen-port 3690 /data/svn/repo