LinuxSVN伺服器搭建
1. Ubuntu PC一台,最好是最新的Ubuntu穩定版本2. 執行以下命令安裝subversion:
sudo apt-get updatesudo apt-get install subversion
3. 假設代碼svn倉庫的根路徑定為 /home/svnroot,執行以下命令建立目錄:
sudo mkdir /home/svnroot
4. 建立一個代碼倉庫,假設倉庫名為:example
cd /home/svnrootsudo svnadmin create example
此命令執行完成後會在 /home/svnroot 下多出來一個名為example的目錄,這就是example代碼倉庫了。5. 編輯example倉庫的存取權限
即:修改 /home/svnroot/example/conf下的三個檔案:authz passwd svnserve.conf
其中:
passwd 中儲存了使用者名稱和密碼
authz 中儲存了使用者組定義及各目錄的存取權限定義
svnserve.conf 中儲存了本代碼倉庫使用的配置(是否允許匿名使用者?指定使用者名稱和密碼資料庫...)
這裡給出一個典型的配置:
passwd執行個體:
[users]xiaoming = 1111xiaowang = 2222xiaoli = 3333laowang = 4444shuangshuang = 5555dashi = 6666
authz執行個體(admin可以讀寫所有目錄,dev能讀寫branch,dev唯讀trunk/tag):
[aliases]# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average[groups]admin = xiaolidev = laowang,shuangshuang,dashi,xiaowang,xiaoming[/]@admin = rw@dev = r[/trunk]@admin = rw@dev = r[/tag]@admin = rw@dev = r[/branch]@admin = rw@dev = rw
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 = noneauth-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[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
6. 添加svn服務為系統自啟動項目
- 建立svnd.sh ,內容如下
#!/bin/bashsvnserve -d -r /home/svnroot
將這個檔案放在 /etc/init.d/svnd.sh
這個指令碼的功能:啟動svn服務,只有在啟動服務後,外部的機器才能通過各種svn工具來訪問svn伺服器。
- 添加可執行許可權
sudo chmod a+x /etc/init.d/svnd.sh
- 編輯 rc.local
vim /etc/rc.local
在exit 0之前,加上 /etc/init.d/svnd.sh
- 重啟伺服器,然後執行命令:
ps -e | grep svnserve
從命令結果來檢查svn服務是否已經自動的隨系統啟動。