以前用過一次 可是沒有真正的用起來 只是知道了一些基本概念html
好了 決定開始真正的用這個svn了服務器
參考大神http://www.cnblogs.com/wrmfw/archive/2011/09/08/2170465.htmlless
搞來搞去發現實際上是創建一個svn以後把每一個項目都裝在這個svn目錄下的不一樣文件夾裏(也是試出來的小領悟)ide
一切以實例爲主,開始吧svn
個人svn目錄建在 /home/user/svn/下ui
則先創建了這個文件夾後,在這下面創建svn目錄結構this
mkdir /home/user/svn svnadmin create --fs-type fsfs /home/user/svn
以後,我以管理兩個項目爲例,一個叫pro_1,一個叫pro_2,他們分別在/home/user/projects/pro_1和/home/user/projects/pro_2下面。spa
svn mkdir file:///home/user/svn/pro_1 -m "Initial create pro_1 directory" svn import /home/projects/pro_1 file:///home/user/svn/pro_1 -m "Initial import pro_1"
svn mkdir file:///home/user/svn/pro_2 -m "Initial create pro_2 directory" svn import /home/projects/pro_2 file:///home/user/svn/pro_2 -m "Initial import pro_2"
這裏有個小細節,就是在import的時候,是將pro_1/pro_2下的文件進行import,因此須要事先建好文件夾來import。code
接着這兩個文件已經搞定了,來開始配置不一樣文件的訪問權限。在/home/user/svn下找到conf文件夾,下面開始來。orm
先改svnserve.conf,去掉全部有效的註釋行,就能夠了
### This file controls the configuration of the svnserve daemon, if you ### use it to allow access to this repository. (If you only allow ### access through http: and/or file: URLs, then this file is ### irrelevant.) ### Visit http://subversion.tigris.org/ for more information. [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 conf directory. ### 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 conf ### directory. 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. ### If two repositories have the same authentication realm, they should ### have the same password database, and vice versa. The default realm ### is repository's uuid. realm = Welcome to my svn
anon-access = read 表明的是未驗證經過用戶的權限;auth-access = write表明的是驗證經過用戶的權限;password-db = passwd表明的是用戶名密碼文件所在地址,一般就放在了conf文件夾下,就不用改了;authz-db = authz表明的是訪問權限的配置文件所在地,默認也是在conf文件夾下,也默認不改,realm = Welcome to my svn就是默認的一個歡迎語,在訪問的時候會出現,隨意。
接着,來搞passwd
### 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] root = root tom = tom helen = helen
大概就是這個意思,再來看authz
### This file is an example authorization file for svnserve. ### Its format is identical to that of mod_authz_svn authorization ### files. ### As shown below each section defines authorizations for the path and ### (optional) repository specified by the section name. ### The authorizations follow. An authorization line can refer to a ### single user, to a group of users defined in a special [groups] ### section, or to anyone using the '*' wildcard. Each definition can ### grant read ('r') access, read-write ('rw') access, or no access ### (''). [groups] admin = root user0 = tom user1 = helen [/pro_1] @admin = rw @user0 = r * = [/pro_2] @admin = rw @user1 = r * =
這裏的pro_1和pro_2是根據立刻的開啓svn服務器的指令相關的,反正意思就是pro_1能夠root和tom訪問,pro_2能夠root和helen訪問。
接下來開啓svn服務器就行了
svnserve -d -r /home/user/svn
用戶tom想要訪問pro_1,則
svn ls svn://172.25.31.153/pro_1
好像第一次進入要輸入用戶名和密碼,若是想要更換身份的話
svn ls svn://172.25.31.153/pro_2 --username helen --password helen
這個好像進入一次用這個用戶名,接下來的訪問都默認用這個身份,除非新的--username XXX --password XXX出現。
祝各位玩的順利