歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> 關於Linux

LinuxSVN服務器搭建

1. Ubuntu PC一台,最好是最新的Ubuntu穩定版本

2. 執行以下命令安裝subversion:

sudo apt-get update
sudo apt-get install subversion

3. 假設代碼svn倉庫的根路徑定為 /home/svnroot,執行以下命令新建目錄:

sudo mkdir /home/svnroot

4. 新建一個代碼倉庫,假設倉庫名為:example

cd /home/svnroot
sudo svnadmin create example
此命令執行完成後會在 /home/svnroot 下多出來一個名為example的目錄,這就是example代碼倉庫了。

5. 編輯example倉庫的訪問權限

即:修改 /home/svnroot/example/conf下的三個文件:authz passwd svnserve.conf

其中:
passwd 中保存了用戶名和密碼
authz 中保存了用戶組定義及各目錄的訪問權限定義
svnserve.conf 中保存了本代碼倉庫使用的配置(是否允許匿名用戶?指定用戶名和密碼數據庫...)
這裡給出一個典型的配置:

passwd實例:

 

[users]
xiaoming = 1111
xiaowang = 2222
xiaoli = 3333
laowang = 4444
shuangshuang = 5555
dashi = 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 = xiaoli
dev = 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 = 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
[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/bash
svnserve -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服務是否已經自動的隨系統啟動。
Copyright © Linux教程網 All Rights Reserved