今天看大神的博客部署了一下svn,期间遇到各种问题,特写此博客重新将svn在centos下的部署和各种问题的解决方案重新旅顺一下。
yum install -y subversion
svnserve --version
出现版本号说明安装成功了~
mkdir /var/svn #我这里把版本库放在了var目录下的svn文件夹,方便管理
svnadmin create /var/svn/repo0 #我这里将svn作为所有版本库的目录,并创建了一个名为repo0的版本库
创建版本库后,在当前版本库目录中会生成下面的文件,其中我们关心的是配置文件。
[root@localhost svn]# ls
repo0
[root@localhost svn]# cd repo0
[root@localhost repo0]# ls
conf db format hooks locks README.txt
[root@localhost repo0]# pwd
/var/svn/repo0
[root@localhost repo0]# cd conf
[root@localhost conf]# ls -a
. .. authz passwd svnserve.conf
passwd文件管理svn用户密码
### 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
user0 = user0passwd
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]
team0=user0 #这里代表将user0分在了team0这个小组中
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe
[/]
@team0=rw #服务team0用户组读写权限
# [/foo/bar]
# harry = rw
# &joe = r
# * =
# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
[general]
### These options control access to the repository for unauthenticated
### and authenticated users. Valid values are "write", "read",
### and "none". The sample settings below are the defaults.
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 #密码文件为当前目录下的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
svnserve -d -r /var/svn/
ps -aux |grep svn
kill -9 进程id
$ mkdir MyProject
$ mkdir MyProject/trunk
$ mkdir MyProject/branches
$ mkdir MyProject/tags
svn import MyProject svn://**svn服务器外网ip**/repo0/MyProject -m "first import project"
svn co svn://**svn服务器外网ip**/repo0/MyProject
注:可以使用systemctl status svnserve.service来查看svn当前状态
svn://192.168.20.242/MyProject1,然后要求输入用户名和密码。如果用户名和密码输入出错了,强行确定后。问题来了!会出现,以下错误信息:
org.tigris.subversion.javahl.ClientException
Authorization failed
这时要清理一下svn用户登录缓存
rm ~/.subversion/auth
遇到
svn: Valid UTF-8 data
(hex: 47 64 20 53 63)
followed by invalid UTF-8 sequence
(hex: e9 6e 69 63)
或者
svn Error normalizing log message to internal format
这样的错误的原因是所提交的文件中包含非utf8的编码,进入configrm
vim ~/.subversion/config
修改log-encoding值为你文件的编码
[miscellany]
### Set global-ignores to a set of whitespace-delimited globs
### which Subversion will ignore in its 'status' output, and
### while importing or adding files and directories.
### '*' matches leading dots, e.g. '*.rej' matches '.foo.rej'.
# global-ignores = *.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo
# *.rej *~ #*# .#* .*.swp .DS_Store
### Set log-encoding to the default encoding for log messages
log-encoding = binary
### Set use-commit-times to make checkout/update/switch/revert
### put last-committed timestamps on every file touched.
# use-commit-times = yes
### Set no-unlock to prevent 'svn commit' from automatically
### releasing locks on files.
# no-unlock = yes
### Set mime-types-file to a MIME type registry file, used to
### provide hints to Subversion's MIME type auto-detection
### algorithm.
# mime-types-file = /path/to/mime.types
### Set preserved-conflict-file-exts to a whitespace-delimited
当然你也可以给文件转编码
总结:svn配置过程中由于系统环境和版本问题会遇到各种突发问题,多百度谷歌stackoverflow就好了。