一、检查是否已安装

# svnserve --version

如果出现下列提示,则代表没有安装

-bash: svnserve: command not found

如果出现下列提示,则代表已经安装了,直接跳到四步

svnserve, version 1.7.14 (r1542130)
   compiled Apr 11 2018, 02:40:28

Copyright (C) 2013 The Apache Software Foundation.
This software consists of contributions made by many people; see the NOTICE
file for more information.
Subversion is open source software, see http://subversion.apache.org/

The following repository back-end (FS) modules are available:

* fs_base : Module for working with a Berkeley DB repository.
* fs_fs : Module for working with a plain file (FSFS) repository.

Cyrus SASL authentication is available.

二、安装

# yum install -y subversion

三、再次检查是否已安装

# svnserve --version

四、创建并进入到储存版本库的目录

# mkdir /data/svn-repository
# cd /data/svn-repository

五、创建一个版本库(项目)
test为版本库的名称

# svnadmin create test

六、显示版本库目录的文件列表

# ls test
名称类型说明
conf目录配置文件目录
conf/authz文件负责账号权限的管理,控制账号是否读写权限
conf/passwd文件负责账号和密码的用户名单管理
conf/svnserve.conf文件版本库配置文件
db目录版本数据存储目录
hooks目录版本库钩子脚本文件目录
locks目录db锁文件和db_logs锁文件的目录,用来追踪存取文件库的客户端
format文件存储一个整数的文件,此整数代表库层次结构版本
README.txt文件说明文件

七、设置全局配置
默认情况下,都是使用版本库目录下conf目录的配置,一两个项目还没问他,但是项目一多,管理就很麻烦了。
先把配置目录复制出来,作为全局配置

# cp -R test/conf conf

八、新增该版本库的用户
打开passwd文件

# vi conf/passwd

在文件末新增一行,输入用户名jwj和密码123456

### 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
jwj = qq2254

九、设置版本库用户的权限
打开authz文件

# vi conf/authz

jwj用户赋予test版本库根目录的读写权限

### 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

[test:/]
jwj = rw

当然,还有更多权限的写法,下面列出部分,想详细了解的话,请查阅其他资料

十、设置svn服务开机自启

#vi /etc/init.d/svn

然后输入以下内容

#!/bin/sh
# chkconfig: 2345 85 85
# processname: svn

svn_bin=/bin
svn_port=3690
svn_home=/mnt/svn-repository
svn_config=/mnt/svn-repository/conf/svnserve.conf

if [ ! -f "$svn_bin/svnserve" ]
then
    echo "svnserver startup: cannot start"
exit
fi

case "$1" in
    start)
        echo "Starting svnserve..."
        $svn_bin/svnserve -d -r $svn_home --config-file $svn_config --listen-port $svn_port
        echo "Successfully!"
    ;;
    stop)
        echo "Stoping svnserve..."
        killall svnserve
        echo "Successfully!"
    ;;
    restart)
        $0 stop
        $0 start
    ;;
    *)
        echo "Usage: svn { start | stop | restart } "
        exit 1
    ;;
esac

给文件添加可执行权限

# chmod +x /etc/init.d/svn

开启开机自启动

# chkconfig svn on

十一、启动svn

# service svn start

标签: none

添加新评论