一、軟體安裝
1、Apache伺服器安裝
[[email protected] ~]#apt-get install apache2
Apache伺服器重新開機指令:
[[email protected] ~]# /etc/init.d/apache2 restart
[[email protected] ~]# service apache2 restart
3、Subvsion安裝
[[email protected] ~]#apt-get install subversion
2、SVN WebDAV插件
[[email protected] ~]#apt-get install libapache2-svn
二、配置
配置檔案路徑為:
/etc/apache2/mods-available/dav_svn.conf
配置項包括:
- 路徑配置
- 認證配置
- 授權配置
1、路徑配置
包括兩個路徑:一個HTTP位址中的通路路徑,在<Location>标簽是配置;一個是SVN庫的根路徑,在配置項SVNParentPath中配置。
2、認證配置
認證配置包括兩種類型:Basic和Digest。
3、授權配置
按路徑控制通路權限。
注意:按路徑控制通路權限與匿名使用者可以讀SVN不能同時配置。
參考配置檔案如下:
# 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>
# Uncomment this to enable the repository
DAV svn
# Set this to the path to your repository
#SVNPath /var/lib/svn
# 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/apache/.SVN_REPOS
# 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
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.passwd
# The following three lines allow anonymous read, but make
# committers authenticate themselves. It requires the 'authz_user'
# module (enable it with 'a2enmod').
#<LimitExcept GET PROPFIND OPTIONS REPORT>
Require valid-user
#</LimitExcept>
# To enable authorization via mod_authz_svn (enable that module separately):
<IfModule mod_authz_svn.c>
AuthzSVNAccessFile /etc/apache2/dav_svn.authz
</IfModule>
</Location>
三、常用操作
1、SVN庫建立
[[email protected] ~]# svnadmin create /path/to/repo/path
[[email protected] ~]# chown -R www-data /path/to/repo/path
2、認證使用者添加
1)Basic認證
[[email protected] ~]# htpasswd –cm /etc/apache2/dav_svn.passwd user_name
注意:-c參數為重新建立密碼檔案。
2)Digest認證
[[email protected] ~]# htdigest -c /etc/apache2/dav_svn.htdigest "Subversion repository" usr_nm
[[email protected] ~]# htgidest /etc/apache2/dav_svn.htdigest "Subversion repository" other_usr
3、SVN按路徑授權配置
# [groups]
# g_dev = user1, user2
#
# [repo:path]
# user_name = rw
# @g_dev = r
[techdoc:/]
liming = rw
$authenticated = r
$anonymous = r
4、SVN備份與恢複
1)備份
$svnadmin dump /path/to/repo > svn.dump
2)恢複
導入之前必須先建立SVN庫
$svnadmin create repo
$svnadmin load repo < svn.dump
3)庫目錄拷貝
庫目錄整體拷貝也可實作庫的移動,但是隻有Linux系統下做過測試。
五、參考文檔
http://svnbook.red-bean.com/en/1.6/svn.serverconfig.httpd.html
https://help.ubuntu.com/community/Subversion
轉載于:https://my.oschina.net/slothpig/blog/877227