1. svn命令
svn
The command-line client program
svnversion
A program for reporting the state (in terms of revisions of the items present) of a working copy
svnlook
A tool for directly inspecting a Subversion repository
svnadmin
A tool for creating, tweaking, or repairing a Subversion repository
mod_dav_svn
A plug-in module for the Apache HTTP Server, used to make your repository available to others over a network
svnserve
A custom standalone server program, runnable as a daemon process or invokable by SSH; another way to make your repository available to others over a network.
svndumpfilter
A program for filtering Subversion repository dump streams
svnsync
A program for incrementally mirroring one repository to another over a network
2. 部署SVN服務(wù)
2.1 安裝SVN服務(wù)
sudo apt-get install subversion
2.2 創(chuàng)建版本庫
找個(gè)地方放置倉庫
sudo mkdir 目錄路徑
sudo svnadmin create 目錄路徑/repo(我這里叫repo,你們隨便起什么名字)
如我配置的是:
sudo mkdir /home/svn
sudo svnadmin create /home/svn/repo
這里有個(gè)地方要注意的,如果你是用root登錄主機(jī)的話课兄,千萬不要在root的home目錄也就是/root目錄下創(chuàng)建svn文件夾,這樣雖然svn服務(wù)能部署起來六水,但是后面是用apache部署http訪問時(shí)會(huì)因?yàn)闆]有權(quán)限而失敗的。
2.3 了解版本信息
conf --各種配置信息
db --存放svn轉(zhuǎn)儲(chǔ)后的數(shù)據(jù)
format --是一個(gè)文本文件,里面只放了一個(gè)整數(shù)缩擂,表示當(dāng)前文件庫配置的版本號(hào)
hooks --放置hook腳本文件
locks --用來放置svn的db鎖文件和db_logs鎖文件的目錄鼠冕,用來追蹤存取文件庫的客戶端
README.txt
2.4 配置svn服務(wù)
cd conf
authz --定義權(quán)限組
passwd --定義svn用戶名和密碼
svnserve.conf --配置svn服務(wù)
2.4.1 配置svn服務(wù)
sudo vi svnserve.conf
去掉下面參數(shù)的注釋,根據(jù)自己的需求更改參數(shù)的值
anon-access = none #匿名訪問權(quán)限胯盯,默認(rèn)read懈费,none為不允許訪問
auth-access = write #認(rèn)證用戶權(quán)限
password-db = passwd #用戶信息存放文件,默認(rèn)在版本庫/conf下面博脑,也可以絕對(duì)路徑指定文件位置
authz-db = authz #用戶組信息存放文件憎乙,默認(rèn)在版本庫/conf下面,也可以絕對(duì)路徑指定文件位置
2.4.2 配置svn用戶及密碼
sudo vi passwd
格式是用戶名=密碼叉趣,如chengj=123456
2.4.3 配置用戶組
sudo vi authz
[groups] #定義組的用戶
manager = chengxj,foo,bar #manager組
core_dev = alice #core_dev組
[repo:/] #以根目錄起始的repo版本庫泞边,地址為svn://主機(jī)IP/repo
@manager = rw #manager組擁有讀寫權(quán)限
* = r #其他用戶只有讀權(quán)限
[repo:/media] #repo版本庫下media目錄,地址為svn://主機(jī)IP/repo/media
@core_dev = rw #core_dev對(duì)repos版本庫下media目錄為讀寫權(quán)限
2.5 啟動(dòng)服務(wù)
sudo svnserve -d -r 版本庫父目錄路徑
如我配置的是:
sudo svnserve -d -r /home/svn
查看是否啟動(dòng)成功疗杉,可看的監(jiān)聽3690端口
sudo netstat -antp |grep svnserve
tcp 0 0 0.0.0.0:3690 0.0.0.0:* LISTEN 28967/svnserve
如果想關(guān)閉服務(wù)阵谚,可使用pkill svnserve
可以在客戶機(jī)使用命令行或者svn客戶端checkout倉庫使用,這里就不展開了
3. 配置HTTP訪問
在完成上面的配置后烟具,就可以通過svn客戶端訪問倉庫的內(nèi)容了梢什,但是仍然無法在瀏覽器中訪問,我們可以通過配置apache服務(wù)器來使用HTTP訪問svn庫朝聋。
3.1 安裝apache及其相關(guān)軟件
sudo apt-get install apache2 libapache2-svn apache2-utils
3.2 修改版本庫權(quán)限
sudo chmod -R 777 版本庫路徑
sudo chown -R www-data:www-data 版本庫路徑
注意:如果你要建多個(gè)庫嗡午,每個(gè)庫都要給他權(quán)限
3.3 配置apache2
sudo vi /etc/apache2/mods-available/dav_svn.conf
# dav_svn.conf - Example Subversion/Apache configuration
#
# For details and further options see the Apache user manual and
# the Subversion book.
#
# NOTE: for a setup with multiple vhosts, you will want to do this
# configuration in /etc/apache2/sites-available/*, not here.
# <Location URL> ... </Location>
# URL controls how the repository appears to the outside world.
# In this example clients access the repository as http://hostname/svn/
# Note, a literal /svn should NOT exist in your document root.
<Location /svn> # 配置svn的http路徑,如這里配置了svn后路徑為http://hostname/svn/
# Uncomment this to enable the repository
DAV svn
# Set this to the path to your repository
#SVNPath /root/SVN/repo/
# Alternatively, use SVNParentPath if you have multiple repositories under
# under a single directory (/var/lib/svn/repo1, /var/lib/svn/repo2, ...).
# You need either SVNPath and SVNParentPath, but not both.
SVNParentPath /home/svn # 當(dāng)在一個(gè)父目錄中有多個(gè)庫時(shí)使用SVNParentPath
SVNListParentPath On # 顯示倉庫根目錄
# Access control is done at 3 levels: (1) Apache authentication, via
# any of several methods. A "Basic Auth" section is commented out
# below. (2) Apache <Limit> and <LimitExcept>, also commented out
# below. (3) mod_authz_svn is a svn-specific authorization module
# which offers fine-grained read/write access control for paths
# within a repository. (The first two layers are coarse-grained; you
# can only enable/disable access to an entire repository.) Note that
# mod_authz_svn is noticeably slower than the other two layers, so if
# you don't need the fine-grained control, don't configure it.
# Basic Authentication is repository-wide. It is not secure unless
# you are using https. See the 'htpasswd' command to create and
# manage the password file - and the documentation for the
# 'auth_basic' and 'authn_file' modules, which you will need for this
# (enable them with 'a2enmod').
AuthType Basic # 基本權(quán)限驗(yàn)證功能
AuthName "Subversion Repository" # 權(quán)限名字冀痕,隨便都行
AuthUserFile /etc/apache2/dav_svn.passwd # 保存授權(quán)用戶的賬戶密碼的文件路徑
# To enable authorization via mod_authz_svn (enable that module separately):
#<IfModule mod_authz_svn.c>
#AuthzSVNAccessFile /etc/apache2/dav_svn.authz
#</IfModule>
# The following three lines allow anonymous read, but make
# committers authenticate themselves. It requires the 'authz_user'
# module (enable it with 'a2enmod').
# 除了以下描述的GET OPTIONS操作外荔睹,其他的HTTP操作都需要授權(quán)用戶才可以
<LimitExcept GET PROPFIND OPTIONS REPORT>
Require valid-user
</LimitExcept>
</Location>
3.4 創(chuàng)建在瀏覽器中使用的用戶及密碼
sudo htpasswd -c /etc/apache2/dav_svn.passwd 用戶名
,根據(jù)提示輸入密碼
注意言蛇,-c僅僅在沒有dav_svn.passwd文件的情況下使用僻他,即創(chuàng)建第一個(gè)用戶時(shí)使用,若創(chuàng)建之后的用戶仍然使用-c腊尚,則會(huì)把之前創(chuàng)建的用戶覆蓋掉
3.5 啟動(dòng)Apache服務(wù)
sudo /etc/init.d/apache2 restart
然后就可以在瀏覽器中瀏覽了中姜,http://服務(wù)器地址/域名/svn/庫名
注意,如果80端口被其他程序占用跟伏,這里啟動(dòng)apache服務(wù)會(huì)失敗,可以修改/etc/apache2下的ports.conf
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf
Listen 80 # 修改為其他端口
<IfModule ssl_module>
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
然后重啟apache服務(wù)即可
腳本的話正在寫翩瓜,晚點(diǎn)傳到GitHub上去??
參考鏈接
svn安裝
Ubuntu 14.04快速搭建SVN服務(wù)器及日常操作
Ubuntu下搭建http訪問方式的SVN服務(wù)器