前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Linux服务器搭建SVN服务器

Linux服务器搭建SVN服务器

作者头像
jwj
发布2022-05-18 11:38:43
8.6K0
发布2022-05-18 11:38:43
举报
文章被收录于专栏:用户1069690的专栏

一、检查是否已安装

代码语言:javascript
复制
# svnserve --version

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

代码语言:javascript
复制
-bash: svnserve: command not found

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

代码语言:javascript
复制
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.

二、安装

代码语言:javascript
复制
# yum install -y subversion

三、再次检查是否已安装

代码语言:javascript
复制
# svnserve --version

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

代码语言:javascript
复制
# mkdir /data/svn-repository
# cd /data/svn-repository

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

代码语言:javascript
复制
# svnadmin create test

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

代码语言:javascript
复制
# ls test

名称

类型

说明

conf

目录

配置文件目录

conf/authz

文件

负责账号权限的管理,控制账号是否读写权限

conf/passwd

文件

负责账号和密码的用户名单管理

conf/svnserve.conf

文件

版本库配置文件

db

目录

版本数据存储目录

hooks

目录

版本库钩子脚本文件目录

locks

目录

db锁文件和db_logs锁文件的目录,用来追踪存取文件库的客户端

format

文件

存储一个整数的文件,此整数代表库层次结构版本

README.txt

文件

说明文件

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

代码语言:javascript
复制
# cp -R test/conf conf

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

代码语言:javascript
复制
# vi conf/passwd

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

代码语言:javascript
复制
### 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文件

代码语言:javascript
复制
# vi conf/authz

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

代码语言:javascript
复制
### 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服务开机自启

代码语言:javascript
复制
#vi /etc/init.d/svn

然后输入以下内容

代码语言:javascript
复制
#!/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

给文件添加可执行权限

代码语言:javascript
复制
# chmod +x /etc/init.d/svn

开启开机自启动

代码语言:javascript
复制
# chkconfig svn on

十一、启动svn

代码语言:javascript
复制
# service svn start
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019-05-09,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
访问管理
访问管理(Cloud Access Management,CAM)可以帮助您安全、便捷地管理对腾讯云服务和资源的访问。您可以使用CAM创建子用户、用户组和角色,并通过策略控制其访问范围。CAM支持用户和角色SSO能力,您可以根据具体管理场景针对性设置企业内用户和腾讯云的互通能力。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档