ubuntu14.10下搭建svn服务器

1. 安装subversion
$ sudo apt-get install subversion
# apt-get install subversion
p.s. 如果你的系统是linux的其他发行版, 如云主机Amazon linux AMI, centos等 , 可通过 yum来安装, 如下:
# yum install -y subversion
剩下的配置与下面的大同小异了
2. 验证版本
$ svn --version
$ svnserve --version
具体操作信息如下:
xx@ubuntu:~$ svnserve --version
svnserve,版本 1.8.10 (r1615264)
编译于 Aug 21 2014,13:44:15 在 x86_64-pc-linux-gnu

Copyright (C) 2014 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/

下列版本库后端(FS) 模块可用:

* fs_fs : 模块与文本文件(FSFS)版本库一起工作。
* fs_base : 模块只能操作BDB版本库。

Cyrus SASL 认证可用。

xx@ubuntu:~$ svn --version
svn,版本 1.8.10 (r1615264)
编译于 Aug 21 2014,13:44:15 在 x86_64-pc-linux-gnu

Copyright (C) 2014 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/

可使用以下的版本库访问模块:

* ra_svn : 使用 svn 网络协议访问版本库的模块。 - 使用 Cyrus SASL 认证
- 处理“svn”方案
* ra_local : 访问本地磁盘的版本库模块。
- 处理“file”方案
* ra_serf : Module for accessing a repository via WebDAV protocol using serf.
- using serf 1.3.7
- 处理“http”方案
- 处理“https”方案

xx@ubuntu:~$
3. 查看相关路径
$ which svn
$ which svnserve
4. 创建 svn工作区
$ sudo mkdir svn
5. 创建svn版本库
在svn工作区根目录下, 创建版本库
$ sudo svnadmin create 版本库名
创建完版本库后, 在版本库根目录下初始化文件, 如下
xx@ubuntu:/var/svn/ets$ ls
conf  db  format  hooks  locks  README.txt
xx@ubuntu:/var/svn/ets$ 
进入conf目录,在其目录下有以下文件:
xx@ubuntu:/var/svn/ets$ cd conf/
xx@ubuntu:/var/svn/ets/conf$ ls
authz  hooks-env.tmpl  passwd  svnserve.conf
xx@ubuntu:/var/svn/ets/conf$ 
(1) svnserve.conf:  svn服务配置文件
(2) passwd: 用户名口令文件
(3) authz: 权限配置文件
 
svnserve.conf 文件, 该文件配置项分为以下5项:
       (1) anon-access: 控制非鉴权用户访问版本库的权限。
       (2) auth-access:  控制鉴权用户访问版本库的权限。
       (3) password-db: 指定用户名口令文件名。
       (4) authz-db:指定权限配置文件名,通过该文件可以实现以路径为基础的访问控制。
       (5) realm:指定版本库的认证域,即在登录时提示的认证域名称。若两个版本库的认证域相同,建议使用相同的用户名口令数据文件
6. 配置passwd文件
$ sudo 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
# 用户名 = 密码(口令)
admin = admin
如上, 在passwd文件里添加 访问svn的用户名和密码
7. 配置authz文件
$ sudo vim 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]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe

# [/foo/bar]
# harry = rw
# &joe = r
# * =
devteam = admin
# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
[/]
@devteam = rw
* = r
8. 配置svnserve.conf文件
$ sudo vim 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
### directory containing this file.  The specified path may be a
### repository relative URL (^/) or an absolute file:// URL to a text
### file in a Subversion repository.  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
### The groups-db option controls the location of the groups file.
### Unless you specify a path starting with a /, the file's location is
### relative to the directory containing this file.  The specified path
### may be a repository relative URL (^/) or an absolute file:// URL to a
### text file in a Subversion repository.
# groups-db = groups
### 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 = ets
### 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
### The hooks-env options specifies a path to the hook script environment 
### configuration file. This option overrides the per-repository default
### and can be used to configure the hook script environment for multiple 
### repositories in a single file, if an absolute path is specified.
### Unless you specify an absolute path, the file's location is relative
### to the directory containing this file.
# hooks-env = hooks-env

[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
其中, 将下面的项最前面的 # 去掉, 且前面置顶不留空格。
anon-access = read
auth-access = write
password-db = passwd
authz-db = authz
realm = 版本库名
9. 启动和停止svn服务
(1) 启动svn服务
回到svn工作区根目录,即版本库的所有目录
$ sudo svnserve -d -r 版本库名
-d表示后台运行
-r 指定根目录是 版本库/
(2) 停止svn服务
停止svn的服务, 可以通过查找svn的进程并获知其PID, 再用kill -9 (pid)来强行杀掉svn服务进程。
查看svn服务是否启动:
$ lsof -i:3690
$ ps -aux|grep svn
$ ps -ef|grep svn
具体操作如下:
xx@ubuntu:/var/svn/ets/conf$ lsof -i:3690
COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
svnserve 6231   xx    3u  IPv4  40745      0t0  TCP *:svn (LISTEN)
xx@ubuntu:/var/svn/ets/conf$ ps -aux|grep svn
xx         6231  0.0  0.1  73916  2552 ?        Ss   23:01   0:00 svnserve -d -r ets/
xx         6838  0.0  0.1  13676  2104 pts/1    R+   23:49   0:00 grep --color=auto svn
xx@ubuntu:/var/svn/ets/conf$ ps -ef|grep svn
xx         6231   2612  0 23:01 ?        00:00:00 svnserve -d -r ets/
xx         6841   3570  0 23:49 pts/1    00:00:00 grep --color=auto svn
xx@ubuntu:/var/svn/ets/conf$ 
10. 访问svn版本库
版本库URL: svn://ip
如:svn://192.168.247.128
再输入在passwd文件配置的用户名和密码即可
windows下, 建议安装并使用tortoise svn客户端, 官网下载软件安装包和中文语言名安装即可 
 
 
p.s. 如果你在windows系统下安装了vmware workstation, 在vmware安装了虚拟机ubuntu, 且在ubuntu像以上搭建了svn服务器, 那在vmware的菜单可编辑虚拟网络, 使其在物理机win可访问虚拟机ubuntu, 则在虚拟机ubuntu下搭建的svn服务器, 在物理机win下, 通过tortoise svn客户端也可以访问虚拟机ubuntu里的svn远程版本库哦!!!
OK, Enjoy it!!!
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值