Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學

Win7 架設 SVN 伺服器完整教學:Subversion + TortoiseSVN + Windows 服務部署

編輯:Windows 7 系統介紹

在 Windows 7 上部署 Subversion (SVN) 版本控制伺服器,採用 svnserve 獨立服務模式,搭配 TortoiseSVN 客戶端,支援認證、授權、多版本庫、Windows 服務自動啟動。本文記錄軟體準備、安裝、版本庫建立、設定檔修改、服務註冊全流程。

軟體準備 (版本示例)

  • Setup-Subversion-1.7.8.msi (伺服器端核心,含 svnserve.exe)。
  • TortoiseSVN-1.7.11.23600-win32-svn-1.7.8.msi (客戶端,含 Shell 擴充、圖示覆蓋)。

安裝時自訂路徑 (如 D:\SVN\Server、D:\SVN\Client),方便管理。

建立版本庫根目錄與專案庫

  1. 建立根目錄:D:\svn\repository。
  2. 命令列 (管理員) 執行:
    svnadmin create D:\svn\repository\myrepository
  3. 生成標準結構:conf、db、hooks、locks、format、README.txt。

修改版本庫設定檔 (conf/svnserve.conf)

[general]
anon-access = none
auth-access = write
password-db = passwd
authz-db = authz
realm = My SVN Repository
  • 去除各行前 # 且行首不能有空格。
  • anon-access = none 禁止匿名存取。

設定使用者帳號 (conf/passwd)

[users]
admin = admin123
dev1 = dev123
test = test123

格式:用戶名 = 密碼,明文儲存 (svnserve 特性),生產環境建議改用 Apache + mod_dav_svn + LDAP/SSO。

設定權限控制 (conf/authz)

[groups]
admins = admin
developers = dev1
testers = test

[/]
@admins = rw
* =

[myrepository:/]
@admins = rw
@developers = rw
@testers = r
* =

支援群組、路徑級權限 (r=讀、w=寫)、繼承與排除。

啟動 svnserve 服務 (測試用)

svnserve.exe -d -r D:\svn\repository
  • -d:守護進程模式 (背景執行)。
  • -r:指定版本庫根目錄,客戶端 URL 為 svn://IP/專案名。

註冊為 Windows 服務 (開機自啟、服務管理)

  1. 以系統管理員身分開啟 CMD。
  2. 執行:
    sc create SVNService binpath= "D:\SVN\Server\bin\svnserve.exe --service -r D:\svn\repository" displayname= "SVN Server" depend= Tcpip start= auto
  3. 注意:binpath= 等號後必須有空格,路徑含空格需雙引號包裹。
  4. 服務管理員 (services.msc) 中即可見「SVN Server」,狀態「執行中」,啟動類型「自動」。

客戶端連線驗證 (TortoiseSVN)

  1. 右鍵資料夾 →「SVN Checkout...」。
  2. URL:svn://伺服器IP/myrepository。
  3. 輸入帳密 → Checkout 成功,圖示覆蓋正常顯示。

防火牆/網路注意

  • Windows 防火牆需開放 TCP 3690 埠 (svnserve 預設)。
  • 路由器/雲端安全組同樣需放行 3690。
  • 若需 HTTPS/SSL、LDAP 整合、Web 瀏覽倉庫,請改用 Apache + mod_dav_svn 架構。
Copyright © Windows教程網 All Rights Reserved