開始之前,首先需要明白一個概念——版本庫蒂胞。版本庫是用于版本管理的图呢,里面包含了目錄鎖、hook骗随、數(shù)據(jù)倉庫的信息(即文件目錄結(jié)構(gòu)和文件數(shù)據(jù))蛤织、基本的配置信息等。即他不是真正的工作目錄鸿染,配置好相關(guān)信息后也無需對他進行多余操作指蚜。
svn 下載什么的就不多說了。
一涨椒、 創(chuàng)建版本庫目錄(此僅為目錄摊鸡,為后面創(chuàng)建版本庫提供存放位置)
mkdir /opt/work/svn
二、啟動 SVN 服務器
svnserve -d -r /var/svn/svnrepos
若端口已被占用蚕冬,則使用:
svnserve -d -r /var/svn/svnrepos --listen-port 端口號
二免猾、創(chuàng)建svn版本庫
svnadmin create /var/svn/svnrepos/具體項目名
進入 xxx 目錄,可以看到如下結(jié)構(gòu):
conf目錄存放配置信息囤热;
db目錄就是所有版本控制的數(shù)據(jù)文件猎提;
hooks目錄放置hook腳本文件的目錄;
locks用來放置Subversion文件庫鎖定數(shù)據(jù)的目錄旁蔼, 用來追蹤存取文件庫的客戶端锨苏;
format文件是一個文本文件,里面只放了一個整數(shù)棺聊,表示當前文件庫配置的版本號伞租;
我們需要關(guān)注的主要是 conf/
,其中conf/
是配置文件的目錄限佩。
三葵诈、修改配置
進入 conf 目錄:
各個文件意義:
authz:負責賬號權(quán)限的管理,控制賬號是否讀寫權(quán)限
passwd:負責賬號和密碼的用戶名單管理
svnserve.conf:svn服務器配置文件
針對各文件的修改:
- passwd:
賬號密碼文件無需做修改,也是直接將賬號和密碼信息追加到文件中即可驯击,注意格式為:
賬號 = 密碼
例如:admin = 123456
- authz
在末尾添加
[\]
賬號1 = rw
賬號2 = rw
...
rw
表示賦予此賬號可讀寫權(quán)限
- svnserve.conf
原始文件內(nèi)容,都被注釋掉的耐亏,我們只需要去掉4條指定內(nèi)容前注釋即可徊都,如下:
[general]
### These options control access to the repository for unauthenticated
### and authenticated users. Valid values are "write", "read",
### and "none". The sample settings below are the defaults.
anon-access = read
auth-access = write
### The password-db option controls the location of the password
### database file. Unless you specify a path starting with a /,
### the file's location is relative to the directory containing
### this configuration file.
### If SASL is enabled (see below), this file will NOT be used.
### Uncomment the line below to use the default password file.
password-db = passwd
### The authz-db option controls the location of the authorization
### rules for path-based access control. Unless you specify a path
### starting with a /, the file's location is relative to the the
### directory containing this file. If you don't specify an
### authz-db, no path-based access control is done.
### Uncomment the line below to use the default authorization file.
authz-db = authz
### This option specifies the authentication realm of the repository.
...
四、防火墻開啟
多數(shù)情況下服務器安裝完成广辰,配置完成后暇矫,無法連接svn服務器,均是防火墻問題择吊,大家按照如下3條命令逐一執(zhí)行即可
> /sbin/iptables -I INPUT -p tcp --dport 3690 -j ACCEPT
> /etc/init.d/iptables save
> service iptables restart
六李根、客戶端訪問svn服務器
若使用的window下的TortoiseSVN,則直接在checkout中輸入:
svn://ip地址:3690/具體項目名 (iP地址為你linux的ip几睛,xxxx為前文創(chuàng)建的版本庫名稱,3690為svn默認端口)
若使用的為Linux房轿,則:
svn checkout svn://ip地址:3690/xxxx
關(guān)于SVN倉庫,先checkout所森,然后在提交
1囱持、checkout時,提示:URL svn://192.168.1.99/svntest doesn't exist...
奇怪焕济,怎么會提示庫不存在呢纷妆?肯定是哪里配置問題。后來嘗試了半天晴弃,也在網(wǎng)上搜索了很久掩幢,終于發(fā)現(xiàn)問題所在。
如果你的svn庫的路徑為:/opt/work/Ops_old/Ops_old_svn
那么你啟動時上鞠,不能用命令:
svnserve -d -r /opt/work/Ops_old/Ops_old_svn --listen-port 3693
而要用命令:
svnserve -d -r /opt/work/Ops_old --listen-port 3693
而取則用:
svn checkout svn://192.168.2.168:3692/Ops_old_svn