在 Windows XP上安裝 SVN Subversion 服務端
在 Windows XP上安裝 SVN Subversion 服務端
折騰了我一下午加一晚上,終於配置好了。與大家分享下我的經歷。
1安裝
服務端軟體 |
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客戶端 |
首先我們安裝執行Setup-Subversion-1.6.5.msi 安裝介面比較簡單,我們主要關注安裝位置,假定我們安裝在預設位置C:/Program Files/Subversion
接下來安裝TortoiseSVN-1.6.5.16974-win32-svn-1.6.5.msi,預設即可。
2建立svn伺服器
2.1.首先通過圖形介面在C盤建立一個名為svn目錄
2.2.在cmd執行svnadmin create C:/svn/fcrepos
2.3.則此時在svn目錄下會出現fcrepos目錄,修改conf資料夾裡面的svnserve.conf
[general] 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. ### 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 |
2.4.修改passwd,建立使用者名稱和密碼
修改好svnserve.conf後,我們再修改 passwd檔案。加入我們需要的使用者名稱fc和口令123。passwd內容如下:
### This file is an example password file for svnserve. [users] |
3.啟動svnserve,以及客戶端的訪問
我們介紹兩種,一種是以daemon方式呼叫,一種是以Windows Service的方式呼叫。
3.1.Daemon方式
在cmd裡執行svnserve --daemon,則啟動svn伺服器,此時在客戶端通過svncheckout即可訪問,地址:svn://59.64.xxx.xxx/svn/fcrepos,(注意是svn開頭不是http開頭,http開頭的用於基於apache的svn)但這種方式必須cmd視窗必須一直開啟,一旦關閉,則svnserve停止。因此可以考慮採用windows service的方法,即開機自動啟動。
3.2.Windows Service的方式
在系統內新增自動啟動的服務項:
sc create svnservice binpath= "/"C:/Program Files/Subversion/bin/svnserve.exe/" --service " displayname= "SVNService" depend= tcpip start= auto
這裡要特別注意一下sc命令的使用。主要是注意一下=號後面的空格和svn路徑的空格。
若svnserve.exe的路徑中有空格,則必須在路徑前後加入”的轉義符/”。
用此方式啟動的服務,訪問方式與Daemon方式相同,地址:svn://59.64.xxx.xxx/svn/fcrepos。
新增該服務之後,每次系統啟動後會自動啟動svnserve。
但當前因為還沒有重啟電腦,所以需要手動啟動:
net start svnservice
若要停止:
net stop svnservice
若要刪除服務
sc delete svnservice
要刪除前面新增的服務,只需要執行"sc delete svn","svn"就是我們建立服務時使用的名字。
4備註
若要讓一個資料夾脫離SVN控制,刪除該目錄下的“.svn”資料夾即可。
要檢視新增的服務,執行services.msc即可。