CentOS 7下svn服务端搭建以及http协议访问

1、安装subversion

yum install subversion

2、配置

在var/www目录下新建一个文件夹svn,该文件夹下新建一个repo作为Repository。

[yy@localhost www]$ pwd
/var/www
[yy@localhost www]$ mkdir svn
[yy@localhost www]$ svnadmin create svn/repo/
[yy@localhost www]$ cd svn
[yy@localhost svn]$ ls
repo
[yy@localhost svn]$ cd repo
[yy@localhost repo]$ ls
conf  db  format  hooks  locks  README.txt

从这里开始配置svn,首先进入conf文件夹下,

[yy@localhost repo]$ cd conf/
[yy@localhost conf]$ ls
authz  passwd  svnserve.conf

conf文件夹下这三个文件

  • authz 是权限控制文件
  • passwd 是帐号密码文件
  • svnserve.conf 是SVN服务配置文件
2.1 配置passwd文件

vim编辑passwd文件

vim 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
#
yy = 123456
test1 = 123456
test2 = 123456

这里我配置了三个用户,密码都是123456

2.2 配置authz
vim authz
#[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
#
[/]
yy = rw
test1 = rw
test2 = r
* =

配置的内容是[/]表示仓库下的所有文件, yy 和test1有读写权限,test2用户只有读权限,别的用户没有权限。

用户分组这里没有使用,不过使用也很简单。注释中表示分了两组harry_and_sally和harry_sally_and_joe两组,第一组用两个用户,第二组有三个用户。在仓库、baz/fuz的配置中,第一组harry_and_sally的所有用户权限都是可读可写。

格式说明:

版本库目录格式:
[<版本库>:/项目/目录]
@<用户组名> = <权限>
<用户名> = <权限>
2.3 配置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 = read
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 = /var/www/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

主要配置的内容是realm = /var/www/svn。别的是打开注释。

3、启动

[root@localhost www]# svnserve -d -r svn/repo
[root@localhost www]# ps -ef | grep svn
root      65559      1  0 23:14 ?        00:00:00 svnserve -d -r svn/repo
root      65583  64792  0 23:15 pts/1    00:00:00 grep --color=auto svn

这里可以看到svn已经启动。

4、使用小乌龟(Tortoise svn)连接svn

使用svn协议连接svn。可以使用小乌龟

Repository Browser, 输入地址svn://192.168.206.110,即:

在这里插入图片描述

5、使用http协议配置

使用http协议进行配置,可以通过浏览器访问svn仓库。

5.1 安装http相关软件包
yum install httpd  mod_dav_svn  -y
5.2 配置httpd

在文件/etc/httpd/conf/httpd.conf末尾添加如下信息:

<Location /svn>
    DAV svn
     SVNParentPath /var/www/svn/        
    AuthType Basic
    AuthName "SVN Repository"
    AuthUserFile /etc/svn-auth-accounts
    Require valid-user
</Location>
5.3 创建SVN用户

利用httpd包生成的命令“htpasswd”来创建:

*htpasswd -cm /etc/svn-auth-accounts yy    //把用户名“yy”换成自己定义的用户名

说明:选项“-c”是用来创建密码文件/etc/svn-auth-accounts;

选项“-m”是用来给用户创建MD5加密密码;

注意:如果创建第二个用户时,请勿使用“-c”选项,否则会重新生成文件并覆盖原文件

5.4 启动httpd并加入开机启动
systemctl restart httpd
systemctl enable httpd
5.5 浏览器访问

在浏览其中输入svn的地址即可。如
在这里插入图片描述

6、备注

如果仓库权限不够,直接给权限777,野蛮粗暴

chmod 777 svn
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值