現在的Subversion已經足夠穩定,而且已經進入了它的黃金時段。我們看到大量的項目都在使用它完成版本控制項的工作。本文將主要針對Windows平台講述安裝Subversion伺服器的步驟。本文所使用的環境是如下
作業系統 |
Windows XP Professional SP2 |
盡量使用原版,因為有朋友反映在部分類似番茄花園的盜版XP上,由於內部檔案做過最佳化,導致Subversion服務端軟體異常。 |
服務端軟體 |
Setup-Subversion-1.6.5.msi |
Windows MSI installer with the basic win32 binaries – includes binaries for Apache 2.2.x (2.2.9 or higher is required within the 2.2.x series) |
用戶端軟體 |
TortoiseSVN-1.6.5.16974-win32-svn-1.6.5.msi |
常用的GUI用戶端 |
用戶端軟體 |
Slik-Subversion-1.6.5-win32.msi |
命令列工具,如果你習慣用cvs的命令列,那這個你會很適應 |
Subversion的首頁是http://subversion.tigris.org/ 或者你也可以直接點擊這裡下載 Setup-Subversion-1.6.5.msi
TortoiseSVN 的首頁是 http://tortoisesvn.tigris.org/ 你也可以直接點擊這裡下載TortoiseSVN-1.6.5.16974-win32-svn-1.6.5.msi
首先我們安裝運行Setup-Subversion-1.6.5.msi 安裝介面比較簡單,我們主要關注安裝位置,假定我們安裝在預設位置C:\Program Files\Subversion
現在我們建立repository,使用的命令是svnadmin。本例中,我們要在c:\svnroot下建立repository。那麼我們使用的命令列如下:
C:\Program Files\Subversion\bin>svnadmin create c:\svnroot C:\Program Files\Subversion\bin>
|
建立好repository之後,我們要對Server 進行一些簡單的配置。開啟c:\svnroot下的conf目錄,編輯svnserve.conf,修改裡面的內容。
auth-access = write
password-db = passwd
anon-access = read
前面的#去掉,開啟這個注釋。
同時修改anon-access = none
現在svnserve.conf的片斷看起來類似
[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 = 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. 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. ### 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 = My First Repository |
修改好svnserve.conf後,我們再修改 passwd檔案。加入我們需要的使用者名稱joe和口令123。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] # harry = harryssecret # sally = sallyssecret joe = 123 |
現在就可以啟動server了。啟動的方法有很多種,在這裡針對本文的環境我們介紹兩種,一種是以deamon方式調用,一種是以Windows Service的方式調用。
如果是以deamon的方式調用,那麼命令列如下:
C:\Program Files\Subversion\bin>svnserve -d -r c:\svnroot |
服務端開始運行後,我們就可以關注一下用戶端的問題了。TortoiseSVN的安裝我沒有什麼可說的,就是一路的NEXT。這裡我們描述一下我們的用於test的項目。以本文為例假定我們的項目目錄是D:\mytemp\svn_test1,假定目錄下有一個test1.txt檔案。在svn_test1上按右鍵選TortoiseSVN–>Import 在URL of repository裡輸入svn://192.168.159.129/svnroot 點擊OK後,按提示輸入使用者名稱和口令,就可以把項目匯入Subversion
。好了,現在我們可以試一下,看看剛才我們匯入的內容,並開始正常的update,commit工作吧。我們刪除svn_test1裡面的所有檔案。然後在svn_test1目錄上按右鍵選SVN Checkout URL of repository裡輸入的仍是svn://192.168.159.129/svnroot Checkout directory裡輸入的是D:\mytemp\svn_test1 Checkout Depth 選擇Fully recursive,點擊OK後,按提示輸入使用者名稱和口令,這時我們再看svn_test1目錄,就可以看到我們匯出的test1.txt檔案了。
我們開啟test1.txt檔案嘗試修改並更新一下。我們在test1.txt裡加上一行“哈爾濱市,高宏偉 QQ:21807822”,然後我們在svn_test1目錄上按右鍵選svn commit,在message中我們可以輸入一些日誌來標誌本次修改,然後點擊OK,按提示輸入使用者名稱口令就可以提交了。update的操作也是類似,只不過是相反的操作。
介面的操作不太容易用文字來表達,但介面很直觀,相信大家擺弄擺弄就可以搞定。剛才為了保證文章的連續性,我們沒有說明如何以Windows Service 的方式來調用server。產生svn服務的命令如下:
C:\>sc create svn binpath= "C:\Program Files\Subversion\bin\svnserve.exe –service -r c:\svnroot" displayname= "Subversion Server" depend= tcpip start= auto C:\>net start svn
|
這裡要特別注意一下sc命令的使用。主要是注意一下=號後面的空格和svn路徑的空格。
1. 如果你沒有建立服務成功,那你就不要安裝到Program Files目錄下,因為它帶了一個空格,你可以安裝到一個比較簡單的目錄下再試試,如c:\svn_server。
2. 如果安裝到這樣簡單的目錄還不能建立成。那你要注意binpath的等號後面有一個空格。你一定要完全按照上面的格式來寫。
3. 實在不行你就把所有的環境先都配成和本文一樣,然後再直接粘貼過去,這樣可以保證你運行成功。等所有的問題都沒有了。你再按照你的想像重新安裝一次,看看你的問題出在哪兒,這樣也好有個對比。
關於Slik-Subversion我在這裡就先不做探討了,它是一個命令列工具。一般來說GUI就可以滿足你的簡單需要。如果你還有什麼更高的要求,可以再去研究,它就好像cvs一樣好用。非常感謝大家能閱讀我的文章。如果還有什麼問題,請大家與我聯絡QQ:21807822,e-mail: dukejoe@163.com 轉載請註明出處為http://blog.donews.com/dukejoe/archive/2009/09/16/1560917.aspx,並保留作者姓名和本句話,謝謝合作