最近要搭建一個SVN服務器。簡單安裝之后,本地訪問沒有問題,但作為服務器肯定是需要HTTP訪問。搜索之后,以下是我按照網上的資料搭建的過程,以備后用和參考。(所有軟件安裝步驟略,沒有特殊的,如果沒有特殊要求,默認下一步執行完即可,后面再搭建環境的時候,再截圖補充。軟件都已經安裝,全部再重新安一遍比較費時,看客請諒解!)
所需軟件:
Subversion:Setup-Subversion-1.7.9.msi
TortoiseSVN:TortoiseSVN 1.7.11
Apache httpd:httpd-2.2.22-win32-x86-openssl-0.9.8t.msi
1,安裝安裝Subversion,TortoiseSVN ,Apache httpd步驟略,執行“”,下一步即可。
2,配置SVN
生成配置庫:
在一個空目錄里的任意空白位置,選擇右鍵,在彈出的右鍵菜單中選擇

創建成功將收到如下提示。

可以選擇“Create folder structure”,工具會自動生成“trunk”,“tags”,“branches”三個空目錄。
trunk--內容主目錄,用於存放主版本文件
tags—標簽主目錄,用於版本基線
branches--分支主目錄,可將主版本切出多個分支同時進行,各分支完成后,合入主版本
在另一個本地空白位置,可以選擇右鍵—“SVN CheckOut”,生成本地拷貝。

設置用戶驗證
配置SVN鑒權(默認SVN是關閉鑒權的)
打開上一步創建的SVN倉庫,進入conf目錄,打開svnserver.conf文件,找到
svnserver.conf#[general]
#password-db=passwd
改為:
[general]
password-db=passwd
配置用戶必須登錄才能訪問
svnserver.conf### "none"--禁止讀寫
### "read"--只讀
### "write"--讀寫
# anon-access = read ###未登錄
# auth-access = write ###已登錄
啟動密碼文件,並修改passwd文件,添加用戶或用戶組
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 = adnin
並配置權限文件authz,配置目錄權限
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
配置httpd服務及集成SVN
1.運行“Monitor Apache Servers”(安裝后默認已運行,執行文件在“%Apache2.2%\bin\ApacheMonitor.exe”),啟動httpd服務。

2.在瀏覽器中輸入“http://localhost”,顯示如下圖,表示服務里其中成功(此頁面文件在“%Apache2.2%\htdocs\index.html”)。

3.使用文本編輯工具(盡量不適用記事本,會修改文件編碼格式為DOS)打開“%Apache2.2%\conf\httpd.conf”,做如下修改后保存。(注意文件中不能包含漢字)
httpd.conf### 將以下兩行內容去掉注釋:
# LoadModule dav_module modules/mod_dav.so
# LoadModule dav_fs_module modules/mod_dav_fs.so
### 在LoadModule區的最后附加下面這兩行內容:
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
### 在文件最后加上以下內容:
<Location /wl> # svn路徑(http://server:port/wl)
DAV svn # 默認,使用svn
SVNPath E:\repository\wl # SVN的倉庫位置
AuthType Basic # 使用基礎的鑒權類型
AuthName "test" # 鑒權名稱,此名稱會在提示用戶輸入用戶名和密碼時顯示
AuthUserFile E:\repository\wl\httpd\passwd # 用戶及密碼文件位置
AuthzSVNAccessFile E:\repository\wl\httpd\authz # 權限文件位置
Require valid-user # 是否必須鑒權 http方式模式必須鑒權
</Location>
4.將”%Subversion%\bin”下的dll文件拷貝至“%Apache2.2%\bin”下。(開始按網上的方案,拷貝了1個文件,服務一直起不來,后來將所有dll拷貝過去成功了。)
5.生成passwd和authz文件。
passwd和authz### 生成密碼文件命令
%Apache2.2%\bin\htpasswd -c passwd_url <username>
### 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
admin = admin,zwh
users = @admin,test
# [/foo/bar]
# harry = rw
# &joe = r
# * =
# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
[test:/svn/test]
@admin = rw
@users = r
至此,重啟一下httpd服務,在瀏覽器中輸入“http://localhost/wl”,有如下提示,表示整個過程成功。

由於第一次搭建,也犯了一些低級錯誤。整個過程因為是搭建成功后寫的,一些過程沒有圖片。后期再搭建時再補充。