標籤:
SVN作為新一代代碼版本管理工具,有很多優點,管理方便,邏輯明確,安全性高,代碼一致性高。SVN資料存放區有兩種方式,BDB(事務安全表類型)和FSFS(一種不需要資料庫的儲存系統),為了避免在伺服器串連中斷時鎖住資料,FSFS是一種更安全也更多人使用的方式。SVN的運行方式也有兩種,一種是獨立伺服器,另一種是藉助apache服務,各有利弊,下面就介紹一下這兩種方式各自的部署步驟。
一.作為獨立伺服器運行,
1.安裝subversion
#yum install subversion
#mkdir -p /opt/svn //建立svn目錄
#chmod R 777 /opt/svn //修改目錄許可權為777
#svnadmin create /opt/svn/repos //建立一個svn版本倉庫repos (repos 名字自己起)
#cd /opt/svn/repos/conf //進入repos版本倉庫下的設定檔目錄
修改此目錄下的三個設定檔
1) svnserve.conf //配置版本庫資訊和使用者檔案和使用者密碼檔案的路徑、版本庫路徑
#vim svnserve.conf
修改一下幾處:
#anon-access = read
#auth-access = write
#password-db = passwd
將這三行前面的 #號去掉,每行的最左邊不能有空格,改成如下:
anon-access = none //read改為none
auth-access = write
password-db = passwd
realm = repos //改成自己的版本庫
儲存退出
2) 修改authz 檔案,建立svn組和組使用者的許可權
#vim authz
[group]
repos = test,test1 //建立一個repos的組,並添加2個使用者test,test1
[/] //修改根目錄下的許可權
@repos = rw //repos組使用者的許可權為 讀寫
test = rw //test 使用者的許可權為讀寫
* = r //其他使用者的許可權為唯讀
3)passwd 檔案 建立或修改使用者密碼
#vim passwd
test = test //使用者名稱test的密碼為test
test1 = test1 //使用者名稱為test2的密碼為test2
儲存退出
二.設定開機開機檔案
1. 編輯/etc/rc.local
檔案內容如下(在touch /var/lock/subsys/local下面添加一行)
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don’t
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
svnserve -d -r /opt/svn/repos
三.啟動SVN服務
1.啟動svn服務,svn服務預設連接埠為3690,可以使用“netstat -ntlp”命令查看服務啟動是否成功:
#svnserve -d -r /opt/svn/repos
如果已經有svn在運行,可以換一個連接埠運行
svnserve -d -r /opt/svn/repos –listen-port 3391
這樣同一台伺服器可以運行多個svnserve
2.啟動成功後就可以使用了
a.建議採用TortoiseSVN, 串連地址為: svn://your server address (如果指定連接埠需要添加連接埠 :連接埠號碼
b.或者用命令列串連:
svn co svn://ip/
串連上之後就可以使用了。
CentOS 6.4 搭建SVN伺服器