2010年1月5日 星期二

在 Centos 上架設SVN 服務器

**以下的指令,請以 root 執行
1、先檢查是否有安裝 SVN
在 CentOS5 中預設會裝有SVN。
可以使用下面的指令查詢SVN Version
svn --version
svn, version 1.4.2 (r22196)
compiled Aug 10 2009, 18:00:04

## 如果沒有安裝過 SVN Version 和版本比較舊,可以透過下面的指令,進行安裝 or 更新
安裝:yum -y install mod_dav_svn subversion

2、新增 SVN 的管理帳號(這可以看個人的命名習慣)
useradd -d /var/empty svn(這是帳號)

3、進行 SVN Server 相關配置
## 先建立要用來放 SVN 相關的主要目錄(這可以看個人習慣)
mkdir /var/svn

## 放專案資料
mkdir /var/svn/repos

## 放權限管理相關
mkdir /var/svn/etc

## 更改該目錄的擁有者
chown -R svn.svn /var/svn

4、啟動 SVN Server

## 啟動服務
svnserve -d -r /var/svn/repos

5、建立專案名稱(如果有多個專案,只要重覆這個行為就好了)
## 建立每個單獨專案名稱
svnadmin create /var/svn/repos/MyProjectName
chown -R svn.svn /var/svn/repos/MyProjectName

## 配制專案的使用相關設定,每個專案可以獨立設定
vi svnserve.conf
** 可以直接修改舊的設定,或是直接新增
[general]
anon-access = none
auth-access = write
password-db = /var/svn/etc/svn-user.conf
authz-db = /var/svn/etc/svn-authz.conf
realm = My First Repository

說明:
anon-access = none #不允許匿名訪問
auth-access = write #通過驗證的用戶可以讀和寫
password-db = /var/svn/etc/svn-user.conf #每個用戶名單
authz-db = /var/svn/etc/svn-authz.conf #每個用戶權限名單
realm = My First Repository #專案名稱

## 如果有第二個
[general]
anon-access = none
auth-access = write
password-db = /opt/svn/etc/svn-user.conf
authz-db = /opt/svn/etc/svn-authz.conf
realm = My Second Repository

----------------------------------------------------------------------
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 = read
# 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 conf directory.
### 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 conf
### directory. 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
----------------------------------------------------------------------

## 用戶帳號及帳號管理

## 設置用戶帳號
vi /var/svn/etc/svn-user.conf

## 下面是範例,請根據自已需要修改
[users]
harry = harryssecret
sally = sallyssecret
bote = botessecret

說明:
[users] #這是必要的,是表示用戶配置開始
harry = harryssecret # harry 是帳號 , harryssecret 是密碼。注意,是明碼的密碼
sally = sallyssecret # 同上
bote = botessecret # 同上

** 可以把所有的帳號都在同一個檔案上記錄就好了,至於那個帳號要談問什麼專案,可以在權限管理的檔案裡,進行設置。

## 設置帳號權限管理
vi /var/svn/etc/svn-authz.conf

## 下面是範例,請根據自已需要修改
[groups]
MyProjectName = harry
MyProjectName2 = sally

[MyProjectName:/]
@MyProjectName = rw
@MyProjectName2 = r

[MyProjectName2:/]
@MyProjectName2 = rw
bote = rw

參考來源:http://16hot.blog.isyi.com/post/1/552

2 則留言:

  1. [general]
    anon-access = none
    auth-access = write
    password-db = /opt/svn/etc/svn-user.conf <==opt ?
    authz-db = /opt/svn/etc/svn-authz.conf <==opt ?
    realm = My First Repository

    回覆刪除