svn 伺服器在生産環境中的搭建
搭建環境
阿裡雲伺服器 CentOS release 6.7
安裝軟體
yum install subversion -y
建立項目目錄
cd /home/svnuser/svn
svnadmin create test1 #建立項目目錄
檢視配置配置檔案
ls /home/svnuser/svn/test1
conf db format hooks locks README.txt
配置檔案解釋
conf #存放版本庫所用配置檔案的目錄
db #版本資料存儲目錄
format # 存儲一個整數的檔案,此整數代表庫層次結構版本
hooks # 存放版本庫勾子目錄
locks # 存儲庫鎖目錄,用來跟蹤庫的通路者
修改配置檔案 (多個目錄的話實作統一認證)
ls /home/svnuser/svn/test1/conf
authz passwd svnserve.conf
vim svnserve.conf 修改配置檔案
[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
vim authz 修改權限配置檔案
[groups] #定義組
test1=zhangyi 定義組中的使用者
test2=zhanger
# [/foo/bar]
# harry = rw
# &joe = r
# * =
[/] //制定根目錄下的權限
@test1 = rw
* = r //其他使用者隻有讀權限
[svn/test:/] #定義目錄,從啟動目錄下面的下一級目錄開始寫
* =r 其他使用者隻有讀的權限
vim passwd #定義使用者的密碼
[users]
# harry = harryssecret
# sally = sallyssecret
zhangyi = test1
啟動服務
svnserve -d -r /home/svnuser/
檢視是否啟動成功
[root@iZ28zk3a6Z svn]# netstat -anutp | grep 369
tcp 0 0 0.0.0.0:3690 0.0.0.0:* LISTEN 2501/svnserve
設定開機自啟動
vim /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
添加下面一行
svnserve -d -r /home/svnuser/
用戶端通路
下載下傳用戶端tortoiseSVN
打開資源庫浏覽器輸入位址, svn://你的svn伺服器ip:svn/test/
如遇到報錯問題
Unable to connect to a repository at URL 'svn://ip/svn/test
需要清除下緩存
TortoiseSVN -> Settings -> Saved Data
點選個個“Clear”按鈕,把本地緩存都清除了,點選“确定”;
本文轉自 水滴石川1 51CTO部落格,原文連結:http://blog.51cto.com/sdsca/1772980,如需轉載請自行聯系原作者