FreeBSD搭建SVN服務器

我最喜歡使用的OS就是FreeBSD,並且如今恰好有一臺FreeBSD服務器,因此我想把個人SVN服務器遷移到FreeBSD上,再配合hudson和ant就能夠自動編譯了。數據庫

第一步:安裝svn:apache

在安裝它以前先使用命令pkg_delete -f libtool\*  把libtool裏的東西去掉讓它自動更新到最新的,不然安裝時會出錯的。windows

使用ports安裝:服務器

cd /usr/ports/devel/subversion/less

#make install WITHOUT_BDB=yes WITH_MOD_DAV_SVN=yes APXS=/usr/local/sbin/apxs
說明:WITHOUT_BDB=yes 這是不使用BerkleyDB才加上的,你願意使用能夠去掉,WITH_MOD_DAV_SVN=yes APXS=/usr/local/sbin/apxs 兩個參數是爲了支持Apache的WebDAV方式
若是不使用apache的話就能夠把對它的支持選項所有去掉。
第二步:建庫:
mkdir /usr/svn         #把它作爲svn的要目錄
svnadmin create /usr/svn/projectOne      #projectOne就是建的第一個庫
第三步:配置權限:
在projectOne下的conf文件夾下有一個conf文件夾,要修改它下面的三個文件:
一、增長一個用戶,打開passwd文件,加入一個用戶名與密碼:如
[users]
# harry = harryssecret
# sally = sallyssecret
test = test   #這裏加入一個test用戶,而且密碼是test
二、修改用戶權限:
打開authz文件,配置以下:(只要修改groups節點)
[groups]
admin = test     #這裏表示有一個admin用戶組,這個用戶組中用一個叫test的用戶
[/]               #這裏是特別須要注意,若是啓動時是指定的svn的要目錄就用/,好比啓動是指定的是
                 #svnserve -r -d /usr/svn/,        若是啓動時指定的是 -r -d /usr/svn/projectOne   這裏就要     用 [/projectOne]b 
@admin = rw           #表示admin組中的用戶都有讀寫權限
* = r
# [repository:/baz/fuz]
三、修改svnserver.conf文件,配置以下:
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                 #指寫權限分配文件
第三步:啓動svn服務:
svn默認啓動的是IPV6的,因此在啓動時須要加一些參數:
svnserve -d -r /usr/svn/ --listen-host=0.0.0.0 --listen-port=3690
這樣就能夠了。tcp

 

好了,開始使用吧,先創建數據庫文件存放位置。我這裏創建/usr/local/svn_data文件夾,而後輸入:svn

  svnadmin create /usr/local/svn_data .

 

編輯/etc/inetd.conf文件,在後面追加:

 

   svn stream tcp nowait root /usr/local/bin/svnserve sveserve -i

 

編輯/etc/rc.conf,增長:

 

   inetd_enable="YES"

 

從新啓動後,這樣服務就會自動啓動了。能夠用netstat -an檢查3690端口是否啓動。

 

  
 

 

每一個數據庫的權限的管理:

 

  打開/usr/local/svn_data/conf文件夾

 

 編輯snvserve.conf, 去掉下列#號:

 

  [general]

 

  non-access = read    // 非認證用戶容許讀

 

  auth-access = write  // 認證用戶容許寫

 

  password-db = passwd  // 密碼記錄文件

 

   authz-db = authz      // 權限認證文件

 

  realm = svn_data     // 區域標誌,隨便填

 

添加用戶,編輯passwd:

 

  去掉[users]前#號,添加用戶如: 

 

   [users]

 

   admin = 123

 

   user1 = a

 

權限設置,編輯authz,去掉[groups]前#號,設置以下:

 

   [groups]

 

   Manage = admin        // 管理組

 

   user = user1          // 用戶組

 

 

 

   [/]                   // 根目錄權限

 

   @Manage = rw          // 管理組權限

 

   @user = r             // 用戶組權限

 

   * = r                 // 其餘用戶權限

 

 

 

   [/text]

 

   @Manage = rw

 

   @user = rw

 

   * = r

 

   ...

 

 

 

  綠色字體部分不要寫入配置裏,只供說明!!

 

 

 

  客戶端我用的是windows,因此裝TortoiseSVN,用Visual Studio的話裝Ankh插件。

 

先介紹這麼多吧,後面的我還要繼續摸索。
相關文章
相關標籤/搜索