本文以ubuntu系統進行安裝。
1、安裝svn服務器
apt-get install subversion
輸入 y 回車確認安裝。
安裝完畢后可以用 下邊的命令查看是否安裝完成,如果現實出版本號和版權信息等等就證明安裝完成。
svn --version
svn --version 成功后展示如下信息 svn, version 1.8.8 (r1568071) compiled Aug 20 2015, 12:51:30 on x86_64-pc-linux-gnu Copyright (C) 2013 The Apache Software Foundation. This software consists of contributions made by many people; see the NOTICE file for more information. Subversion is open source software, see http://subversion.apache.org/ The following repository access (RA) modules are available: * ra_svn : Module for accessing a repository using the svn network protocol. - with Cyrus SASL authentication - handles 'svn' scheme * ra_local : Module for accessing a repository on local disk. - handles 'file' scheme * ra_serf : Module for accessing a repository via WebDAV protocol using serf. - using serf 1.3.3 - handles 'http' scheme - handles 'https' scheme
2、創建版本庫
首先創建目錄,根據你的需要創建svn目錄。我目錄是:/usr/svn/test
然后創建版本倉庫:
svnadmin create /usr/svn/test
3、配置svn服務器
創建版本倉庫后再 test/conf文件夾下生成了四個配置文件:authz hooks-env.tmpl passwd svnserve.conf
①、首先 svnserve.conf里邊配置了版本庫的權限,需要把下邊5行的注釋打開,一定注意,去掉#號的同時把空格去掉,否則svn服務不能正常運行
anon-access = none
#控制非鑒權用戶訪問版本庫的權限。取值范圍為"write"、"read"和"none"。即"write"為可讀可寫,"read"為只讀,"none"表示無訪問權限。缺省值:read
auth-access = write
#控制鑒權用戶訪問版本庫的權限。取值范圍為"write"、"read"和"none"。即"write"為可讀可寫,"read"為只讀,"none"表示無訪問權限。缺省值:write
password-db = passwd
#指定賬戶密碼配置文件,當前文件夾下的passwd文件
authz-db = authz
#權限配置文件,當前文件夾下的authz文件
realm = first
#版本庫的認證域,即在登錄時提示的認證域名稱。若兩個版本庫的 認證域相同,建議使用相同的用戶名口令數據文件。缺省值:一個UUID(Universal Unique IDentifier,全局唯一標示)
②、配置passwd
如下代碼,配置了用戶名為test的用戶,並為其創建了密碼test123.如需要配置多用戶就多寫幾個吧,記得換行
### This file is an example password file for svnserve.
### Its format is similar to that of svnserve.conf. As shown in the
### example below it contains one section labelled [users].
### The name and password for each user follow, one account per line.
[users]
# harry = harryssecret
# sally = sallyssecret
test=test123
③配置authz權限
下邊的代碼為test用戶創建了讀和寫的權限。
[groups] # harry_and_sally = harry,sally # harry_sally_and_joe = harry,sally,&joe # [/foo/bar] # harry = rw # &joe = r # * = # [repository:/baz/fuz] # @harry_and_sally = rw # * = r [/] test=rw
如果用戶較多,需要分角色划分權限參考下邊代碼
這段代碼,為test創建了admin的角色,為ttt用戶創建了user的角色,最后使用@符號為角色創建權限,admin角色讀寫權限,user角色讀權限。
[groups] # harry_and_sally = harry,sally # harry_sally_and_joe = harry,sally,&joe # [/foo/bar] # harry = rw # &joe = r # * = admin=test
user=ttt # [repository:/baz/fuz] # @harry_and_sally = rw # * = r [/] @admin=rw
@user=r
ok,配置已經完成,讓我們啟動svn服務器試試吧
執行命令:
svnserve -d -r /usr/svn
啟動服務器,-d表示守護線程后台運行,-r表示指定目錄。注意:不要寫成svnserve -d -r /usr/svn/test。否則雖然服務可正常啟動,但是客戶端用的時候可能會產生問題
查看是否啟動成功:
ps -ef | grep svnserve
如果結果為兩個線程在運行,一般是成功了。
4、客戶端訪問
下載客戶端不在贅述。
svn地址:svn://ip/test 然后輸入用戶名test和密碼test123確認。
是不是連上了呢?如果沒有檢查是否清除了舊的數據信息,
清除舊數據方法:右鍵->tortoisesvn->setting->Saved Data,都clear掉吧。
最后補充關閉svn服務器的方法:使用ps -ef | grep svnserve查看進程后,記住pid,然后 kill -9 pid 就可以關閉了。