首先,感謝jsntghf和星辰的天空的好文分享,不是他們的文章,我估計須要花費更多的精力和時間。在這裡我隻是對他們文章的潤色和本身測試遇到問題的标注。html
Mac自帶了svn伺服器和用戶端,是以隻須要簡單配置一下就可使用apache
1. 建立svn repository伺服器
Shell代碼微信
svnadmin create /Users/mac22/svn/repository
svnadmin: E000002: Repository creation failed
svnadmin: E000002: Could not create top-level directory
svnadmin: E000002: Can't create directory '/Users/mac22/svn/repository': No such file or directory
注:mac22是目前登陸的使用者名,你須要把它更換成你本身的使用者名,在建立的時候確定已經svn/repository已經存在,上面的錯誤就是我沒有建立svn/repository形成的網絡
若是在終端輸入svnadmin create /Users/mac22/svn/repository 代碼,無提示說明建立成功,以下圖所示:less
2. 配置svn使用者權限/Users/mac22/svn/repository/conf/目錄下存在3個檔案: authz、passwd、snvserve.confide
你能夠選擇使用文本編輯打開,也可使用終端打開,我這裡選擇了後者svn
Shell 代碼測試
martins-mac:conf mac22$ cd /Users/mac22/svn/repository/conf
martins-mac:conf mac22$ ls
authz passwd svnserve.conf
martins-mac:conf mac22$ vi authz
解釋一下主要的幾個指令:cd:進入某一個目錄;ls:浏覽目前目錄的子目錄 vi: 對檔案進行編輯
authz 使用者權限配置設定内容顯示以下,而後按"i"鍵進行編輯:ui
### 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,
### - a group of users defined in a special [groups] section,
### - an alias defined in a special [aliases] section,
### - all authenticated users, using the '$authenticated' token,
### - only anonymous users, using the '$anonymous' token,
### - anyone, using the '*' wildcard.
###
### A match can be inverted by prefixing the rule with '~'. Rules can
### grant read ('r') access, read-write ('rw') access, or no access
### ('').
[aliases]
# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average
# 使用者組
[groups]
# admins是組名,admin是組員,能夠寫多個,用”,“分隔.如admins=admin,master
admins=admin
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe
# [/foo/bar]
# harry = rw
# &joe = r
# * =
# 設定/目錄權限
[/]
# 這裡的意思是admins組的成員都有rw的權限,rw是讀寫得權限,也能夠寫成admin=rw,隻賦予某一個使用者有讀寫權限
@admins=rw
# 這裡若是不寫的意思是,下一級目錄的使用者不具有繼承關系,也就是沒有通路/的權限,* = r,就是别>的使用者隻能遠觀了, * = rw,就讓其餘的使用者也有繼承關系了,就是也可具有讀寫權限
* =
# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
~
編輯以後,切換到英文輸入法,而後點選esc,接着輸入:wq儲存,若是輸入有誤能夠輸入:q不儲存直接退出
在終端輸入vi passwd編輯passwd,svn使用者和密碼内容以下:
### 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]
# authz 的使用者名對應起來,後面是使用者密碼
admin=123456
# harry=harryssecret
# sally=sallyssecret
修改以後記得儲存
在終端輸入vi svnserve.conf編輯svnserve.conf,svn的配置資訊内容以下:
### 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.apache.org/ for more information.
[general]
### The anon-access and auth-access options control access to the
### repository for unauthenticated (a.k.a. anonymous) users and
### authenticated users, respectively.
### Valid values are "write", "read", and "none".
### Setting the value to "none" prohibits both reading and writing;
### "read" allows read-only access, and "write" allows complete
### read/write access to the repository.
### The sample settings below are the defaults and specify that anonymous
### users have read-only access to the repository, while authenticated
### users have read and write access to the repository.
# anon-access=read匿名使用者有讀的權限
# 禁用匿名使用者讀的權限
anon-access=none
# 登陸使用者的寫的權限
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.
# 這裡須要放開注釋,關聯passwd.
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
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=MyFirst Repository
### The force-username-case option causes svnserve to case-normalize
### usernames before comparing them against the authorization rules in the
### authz-db file configured above. Valid values are "upper" (to upper-
### case the usernames), "lower" (to lowercase the usernames), and
### "none" (to compare usernames as-is without case conversion, which
### is the default behavior).
# force-username-case=none
[sasl]
### This option specifies whether you want to use the Cyrus SASL
### library for authentication. Default is false.
### This section will be ignored if svnserve is not built with Cyrus
### SASL support; to check, run 'svnserve --version' and look for a line
### reading 'Cyrus SASL authentication is available.'
# use-sasl=true
### These options specify the desired strength of the security layer
### that you want SASL to provide. 0 means no encryption, 1 means
### integrity-checking only, values larger than 1 are correlated
### to the effective key length for encryption (e.g. 128 means 128-bit
### encryption). The values below are the defaults.
# min-encryption=0
# max-encryption=256
3. 啟動伺服器
Shell 代碼
martins-mac:conf mac22$ svnserve -d -r /Users/mac22/svn/repository/
martins-mac:conf mac22$ svnserve 啟動svn服務;
-d 标示svnserve将會做為一個服務程式運作在背景 -r 标示将/Users/mac22/svn/repository/做為根目錄(網絡搜尋的,忘求證)
4. 向svn庫導入一個根目錄
Shell代碼
martins-mac:conf mac22$ svn import /Users/mac22/svnroot/ svn://localhost:3690/svnroot --username admin --password 123456 -m "Initial import"
Committed revision 1.
martins-mac:conf mac22$ 若是出現上面Committed revision 1.說明根目錄建立成功
注:由于我以前已經建立了一個svn,是以這裡為了區分用了一個端口3690,若是你以前沒有建立過,就不須要用端口,直接svn://localhost/svnroot
5. 簽出根目錄
Shell代碼
martins-mac:conf mac22$ cd /Users/mac22/svncheckout/
martins-mac:svncheckout mac22$ svn checkout svn://localhost/svnroot --username=admin --password=123456
Checked out revision 1.
martins-mac:svncheckout mac22$ 解釋一下上面代碼,先進入你須要簽出的目錄,而後執行簽出,成功以後,會看到以下圖所示:
6. 其餘svn用戶端連結
我我的推薦使用CornerStone,雖然界面不太漂亮,可是比較實用
1. 添加Repository
2. 配置svn server
3. 等待片刻,提示成功,顯示一下界面
到這裡要告一段落,下篇将把使用者權限控制補上,若有不便請見諒。若是有建議和問題請回複,謝謝!