Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> 關於 Linux

CentOS 安裝與配置 Subversion (SVN) 版本控制伺服器完整指南

編輯:關於 Linux

Subversion (SVN) 是集中式版本控制系統,適合團隊協作管理原始碼與文件。本文記錄 CentOS 上透過 yum 安裝、建立版本庫、啟動 svnserve、配置存取權限(svnserve.conf、passwd、authz)的完整流程。

1. 安裝 Subversion

yum install subversion -y

2. 建立版本庫

mkdir -p /var/svn/repositories
cd /var/svn/repositories
svnadmin create rock-eng
# 版本庫路徑:/var/svn/repositories/rock-eng

3. 啟動 SVN 服務

svnserve -d -r /var/svn/repositories
# -d 背景執行,-r 指定版本庫根目錄
# 客戶端連線 URL:svn://server_ip/rock-eng

4. 配置存取權限

cd /var/svn/repositories/rock-eng/conf
vi svnserve.conf

svnserve.conf 關鍵設定:

[general]
# 匿名用戶權限:none/read/write
anon-access = none
# 認證用戶權限
auth-access = write
# 密碼檔位置
password-db = passwd
# 權限檔位置
authz-db = authz
# 認證領域(可自訂)
# realm = My First Repository

編輯 passwd(用戶與密碼)

vi passwd
[users]
# 格式:username = password
harry = harrysecret
sally = sallysecret
dev1 = dev1pass
dev2 = dev2pass

編輯 authz(路徑權限控制)

vi authz
[groups]
admins = harry, sally
developers = dev1, dev2

[/]
@admins = rw
@developers = r
* =

[rock-eng:/trunk]
@developers = rw

[rock-eng:/branches]
@developers = rw
* = r

5. 設定開機自啟

echo 'svnserve -d -r /var/svn/repositories' >> /etc/rc.local
chmod +x /etc/rc.local
# 或建立 systemd service(CentOS 7+)

6. 防火牆開放埠口

iptables -I INPUT -p tcp --dport 3690 -j ACCEPT
service iptables save

7. 客戶端測試

# 檢出
svn checkout svn://server_ip/rock-eng
# 提交
svn commit -m "initial import"
# 更新
svn update

SVN 配置檔示意圖

進階:Apache + mod_dav_svn (HTTP/HTTPS 存取)

若需 WebDAV/HTTPS、綁定 LDAP 認證、瀏覽器檢視,請安裝 httpd、mod_dav_svn 並配置 /etc/httpd/conf.d/subversion.conf,此處不贅述。

Copyright © Windows教程網 All Rights Reserved