工作需要,网上找的两篇文章,很不错,测试有效,推荐给大家
1.Mac OS X上搭建本地SVN服务器
转载:http://xiayong.blog.51cto.com/6292420/1088790
2.配置Apache svn 服务器,允许远程http访问
转载:http://miaoshuanghe.blog.163.com/blog/static/140130476201172114647545/
正文:
1.Mac OS X上搭建本地SVN服务器
1
2
3
4
5
6
7
8
|
$ svnserve --version
svnserve, version 1.6.18 (r1303927)
compiled Aug 4 2012, 19:46:53
Copyright (C) 2000-2009 CollabNet.
Subversion is
open
source
software, see http:
//subversion
.apache.org/
This product includes software developed by CollabNet (http:
//www
.Collab.Net/).
The following repository back-end (FS) modules are available:
* fs_fs : Module
for
working with a plain
file
(FSFS) repository.
|
1
|
$
sudo
mkdir
-p
/data/svn/repositories/local
|
1
|
$
sudo
svnadmin create
/data/svn/repositories/local
|
1
2
3
4
5
6
7
8
9
|
$
cd
/data/svn/repositories/local/
$ ll
total 16
-rw-r--r-- 1 root wheel 229 12 14 01:33 README.txt
drwxr-xr-x 5 root wheel 170 12 14 01:41 conf
drwxr-sr-x 16 root wheel 544 12 14 02:07 db
-r--r--r-- 1 root wheel 2 12 14 01:33
format
drwxr-xr-x 11 root wheel 374 12 14 01:33 hooks
drwxr-xr-x 4 root wheel 136 12 14 01:33 locks
|
1
2
3
4
5
6
|
[general]
anon-access = none
auth-access = write
password-db =
passwd
authz-db = authz
[sasl]
|
1
2
|
administrator = admin@Svnserver
xiayong = xiayong
|
1
2
3
4
5
6
7
8
9
|
[
groups
]
admin = administrator
user = xiayong
[/]
@admin = rw
@user = r
[
local
:/]
@admin = rw
@user = r
|
1
|
$
sudo
svnserve -d -r
/data/svn/repositories
--log-
file
=
/var/log/svn
.log
|
1
2
3
4
5
6
7
|
$ telnet localhost 3690
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is
'^]'
.
( success ( 2 2 ( ) ( edit-pipeline svndiff1 absent-entries commit-revprops depth log-revprops partial-replay ) ) )
|
1
2
3
4
|
$
sudo
mkdir
-p
/tmp/svntemp
$
cd
/tmp/svntemp/
$
sudo
mkdir
tags trunk branches
$
|
1
2
3
4
5
6
7
8
9
10
|
$
sudo
svn
import
-m
'init repo'
/tmp/svntemp/
svn:
//localhost/local
Authentication realm: <svn:
//localhost
:3690> af662c40-23bf-43f4-93fa-8bf7eff40771
Password
for
'root'
:
Authentication realm: <svn:
//localhost
:3690> af662c40-23bf-43f4-93fa-8bf7eff40771
Username: administrator
Password
for
'administrator'
:
Adding
/tmp/svntemp/trunk
Adding
/tmp/svntemp/branches
Adding
/tmp/svntemp/tags
Committed revision 1.
|
1
2
3
4
5
6
|
[
local
:
/branches
]
@user = rw
[
local
:
/tags
]
@user = r
[
local
:
/trunk
]
@user = rw
|
1
2
|
# to run the svnserver on the automatically.
svnserve -d -r
/data/svn/repositories
|
2.配置Apache svn 服务器,允许远程http访问
本文参考了这篇文章
概要:
- svn (subversion) 是一种开源免费的软件项目源文件版本管理工具
- svn 服务器是集中管理 svn 容器,并允许 svn 客户端通过http或者远程登录访问 svn 容器的服务器。
- 本文介绍在 Mac OS 或者 Cent OS 下建立一个允许客户端通过 http 访问的 svn 服务器的方法。
环境:
- Apache:
- OS:
Mac OS X 10.6 Snow Leopard
Mac OS X 10.7 Lion
Cent OS 5.6 Final
预备知识
Mac OS X 对 svn 的兼容:
- 默认安装了如下 svn 命令行工具
- 内置的Apache服务器中预装了 svn 需要的模块 mod_dav.so 和 mod_dav_svn.so
其中 mod_dav.so 默认加载,mod_dav_svn.so 需要手动配置加载。后述。
- 内置 Apache 服务器安装路径:
/etc/apache2/
关于 WebDAV/DeltaV 协议
- 这是两个应用层协议,提供svn需要的远程认证,metadata管理,版本管理和配置管理功能。
- Apache 2.0 开始通过mod_dav模块支持这两个协议。
关于在 Mac OS X 内置的 Apache 中安装模块
- 内置的 Apache 存放模块文件的位置(和通常安装的Apache不同)
/usr/libexec/apache2/
- 本次需要的模块已经存在,所以未进行另外安装。
配置http访问
创建svn容器
- 在自己的用户文件夹下创建一个容器 /Users/nutcracker/repository
配置 Apache
- CentOS :
sudo yum -y install httpd subversion mod_dav_svn
无需手动编辑Apache配置文件。
- Mac OS :
编辑 /etc/apache2/httpd.conf,使 Apache 启动时加载 mod_dav_svn 模块
mod_dav_svn 加载指令要放在mod_dav加载指令的后面。
注意需要用root权限编辑,否则无法保存。
sudo vim /etc/apache2/httpd.conf
- 在 httpd.conf 中添加下面指令来告诉 Apache 将所有路径部分以/repos开头的URL交给位于SVNPath下的 DAV provider 来处理。SVNPath 为前面创建的容器的路径。
<Location /repos>
DAV svn
SVNPath /Users/nutcracker/repository
</Location>
- 重启 Apache (Mac OS X 有自己的启动方法,参照以前的文章)
测试方法
- 创建测试项目
- 添加到容器
- 浏览器访问
- checkout
- 配置成功
Cent OS 和 Lion 下遇到的问题
- errcode="13" Could not open the requested SVN filesystem
- 原因是将容器创建在/home/nutcracker/repos,apache没有访问权限。
- Snow Leopard下将repos文件夹chmod到777就可以访问,而CentOS和Lion不行,chown到apache.apache也不行。原因不明。
- 将容器创建在 /var/www/svn/ 下即可解决。