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 6 安裝與配置 SVN 版本控制伺服器完整指南

編輯:關於 Linux

一、安裝 Subversion 套件

# 1. 安裝 EPEL / RPMForge 源(CentOS 6 預設源版本較舊)
rpm -ivh https://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
yum install --enablerepo=rpmforge,rpmforge-extras subversion -y

# 2. 驗證版本
svnserve --version   # 應顯示 1.7.x 或更新

二、建立專用執行帳號與倉庫

useradd -r -s /sbin/nologin -M svn
passwd svn   # 設定密碼(僅供管理用)

mkdir -p /home/svn/svndata
cd /home/svn/svndata
svnadmin create project1   # 建立名為 project1 的倉庫
chown -R svn:svn /home/svn

三、核心配置檔 project1/conf/svnserve.conf

[general]
anon-access = none       # 匿名不可讀
auth-access = write      # 認證用戶可寫
password-db = passwd     # 密碼檔
authz-db = authz         # 權限檔
realm = Project1 Repo    # 認證域名稱

四、用戶與密碼 project1/conf/passwd

[users]
dev1 = dev1@123
dev2 = dev2@123
qa   = qa@123

五、細粒度權限 project1/conf/authz

[groups]
developers = dev1, dev2
testers = qa

[/]                     # 根目錄
@developers = rw
@testers = r

[/trunk/src]            # 專案核心碼
@developers = rw
* =                     # 其他人無權限

[/branches]             # 分支目錄
@developers = rw
@testers = r

六、啟動服務與開機自啟

# 前景測試
svnserve -d -r /home/svn/svndata --listen-port 3690

# 生產環境建議用 xinetd 或 systemd 管理
cat > /etc/xinetd.d/svnserve <<'EOF'
service svnserve
{
    disable = no
    socket_type = stream
    protocol = tcp
    port = 3690
    user = svn
    server = /usr/bin/svnserve
    server_args = -i -r /home/svn/svndata
    log_on_failure += USERID
}
EOF
service xinetd restart
chkconfig xinetd on

七、客戶端測試

# 棾出專案
svn checkout svn://server-ip/project1/trunk --username dev1

# 提交測試
echo "test" > README.md
svn add README.md
svn commit -m "Initial commit"

八、常見問題快速排查

現象原因解決
Connection refused防火牆封鎖 3690iptables -A INPUT -p tcp --dport 3690 -j ACCEPT
Authorization failed密碼檔格式錯誤或 realm 不符確認 passwd 無空行、realm 一致
Permission deniedauthz 路徑規則不匹配用 svn info 確認實際倉庫路徑

完成上述步驟,即擁有一套輕量、穩定、支援細粒度權限的 SVN 伺服器。

Copyright © Windows教程網 All Rights Reserved