1. 程式人生 > >MAC搭建svn伺服器方法

MAC搭建svn伺服器方法

MAC版本10.9.1預設帶有svn工具

1、開啟終端

輸入svn --version

laoyuliangdeiMac:hello laoyuliang$ svn --version
svn, version 1.7.10 (r1485443)
   compiled Aug 13 2013, 15:31:22

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 access (RA) modules are available:

* ra_neon : Module for accessing a repository via WebDAV protocol using Neon.
  - handles 'http' scheme
  - handles 'https' scheme
* ra_svn : Module for accessing a repository using the svn network protocol.
  - handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
  - handles 'file' scheme
* ra_serf : Module for accessing a repository via WebDAV protocol using serf.
  - handles 'http' scheme
  - handles 'https' scheme
出現如上的現象則證明你的mac自帶有svn

2、建立一個程式碼倉庫

laoyuliangdeiMac:~ laoyuliang$ svnadmin create /Users/laoyuliang/svn

最後的“/Users/laoyuliang/svn“是需要建立的路徑

3、修改程式碼倉庫配置

進入我們建立的程式碼倉庫會出現如下檔案

laoyuliangdeiMac:svn laoyuliang$ ls
README.txt	db		hooks
conf		format		locks
其中的conf下存放著配置檔案,進入config目錄
laoyuliangdeiMac:svn laoyuliang$ cd conf/
laoyuliangdeiMac:conf laoyuliang$ ls
authz		passwd		svnserve.conf
首先修改authz檔案,開啟此檔案做如下修改
[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe
新增如下內容
[groups]
svn_group=laoyl#建立svn_group群組,新增laoyl使用者
[/]
laoyl=rw#給予使用者讀寫許可權,還可以寫成@svn_group=rm給這個群組予以讀寫許可權
*=
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe

passwd檔案內容:
[users]
# harry = harryssecret
# sally = sallyssecret
增加如下:
[users]
laoyl=123456
# harry = harryssecret
# sally = sallyssecret
svnserve.conf檔案內容如下:

將檔案中的如下四句:

#anon-access = read
#auth-access = write
#password-db = passwd
#authz-db = authz
去掉他們的註釋,需要注意的是該四句話#後含有一個空格,必須去除,首字母定格,否則會報錯。

3、啟動svn伺服器

輸入如下指令,啟動svnserver

laoyuliangdeiMac:~ laoyuliang$ svnserve -d -r /Users/laoyuliang/svn/
如果沒有出現任何提示表明啟動成功,如果出現如下提示:

svnserve: E000048: Can't bind server socket: Address already in use

表明已經有svn伺服器啟動了,那麼我們就需要先關閉他,首先需要找到該svn伺服器的後臺程序id好,輸入如下指令:

laoyuliangdeiMac:~ laoyuliang$ ps -e|grep svnserve
27065 ??         0:00.00 /Applications/Xcode.app/Contents/Developer/usr/bin/svnserve -d -r /Users/laoyuliang/svnroot/
27222 ttys000    0:00.00 grep svnserve
出現了已經啟動的svn伺服器的id號是27065,使用kill指令將其殺死:kill 27065

再次啟動svn伺服器就可以了。

4、測試匯入和檢出程式碼

匯入程式碼:

laoyuliangdeiMac:base laoyuliang$ svn import /Users/laoyuliang/Documents/project/base/helloipad/ svn://localhost/svn/helloipad --username laoyl --password 123456 -m "init import"


檢出程式碼:
laoyuliangdeiMac:project laoyuliang$ svn checkout svn://127.0.0.1/svn/helloipad --username=laoyl --password=123456