原文地址(ttlsa运维生存时间):http://www.ttlsa.com/archives/723

http://blog.csdn.net/colinchan/article/details/1865154
軟件獲取地址
apache下載地址
http://httpd.apache.org/
subversion下載地址
http://subversion.tigris.org/
apr下載地址
http://apr.apache.org/
sqllite下載地址
http://www.sqlite.org/download.html

一、準備工作
# mkdir -P /usr/local/src/{tarbag,software}
# cd /usr/local/src/tarbag
apache-2.2.21
# wget http://mirror.bjtu.edu.cn/apache//httpd/httpd-2.2.21.tar.gz
subversion-1.7.2
# wget http://mirror.bjtu.edu.cn/apache/subversion/subversion-1.7.2.tar.gz
apr-1.4.5
# wget http://labs.renren.com/apache-mirror//apr/apr-1.4.5.tar.gz
apr-util-1.3.12
# wget http://labs.renren.com/apache-mirror//apr/apr-util-1.3.12.tar.gz
sqllite-3.7.9
# wget http://www.sqlite.org/sqlite-autoconf-3070900.tar.gz

二、安裝Apache
由於本篇重點講解svn安裝配置,如果Apache安裝有疑問的可參見:
這裡重點講解與SVN有關的參數
如果有安裝過apache,使用如下命令查看
# apachectl -M | grep dav
如下所示,即可跳過
 dav_module (shared)
 dav_fs_module (shared)
Syntax OK
如果沒有則需要重新編譯apache
# ./configure --enable-dav --enable-dav-fs
# make
# make install

三、安裝Apr和Apr-util
# cd /usr/local/src/tarbag/
# tar zxvf apr-1.4.5.tar.gz -C ../software/
# tar zxvf apr-util-1.3.12.tar.gz -C ../software/
# cd ../software/
# cd apr-1.4.5/
# ./configure --prefix=/usr/local/apr/ && make && make install
# cd ../apr-util-1.3.12/
# ./configure  --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr/ &&  make && make install

四、安裝Sqllite
# cd /usr/local/src/tarbag/
# tar zxvf sqlite-autoconf-3070900.tar.gz -C ../software/
# cd ../software/sqlite-autoconf-3070900/
# ./configure --prefix=/usr/local/sqllite && make && make install

五、安裝Subversion
# cd /usr/local/src/tarbag/
# tar zxvf subversion-1.7.2.tar.gz -C ../software/
# cd ../software/subversion-1.7.2/
# ./configure --with-apxs=/usr/local/apache2.2.21/bin/apxs --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-sqllite=/usr/local/sqllite/ && make && make install

六、相關配置
1、配置subversion
拷貝相關類庫
# cd /usr/local/src/software/subversion-1.7.2/
# cp ./subversion/mod_dav_svn/.libs/mod_dav_svn.so  /usr/local/apache2.2.21/modules/
# cp ./subversion/mod_authz_svn/.libs/mod_authz_svn.so  /usr/local/apache2.2.21/modules/
添加svn的驗證文件svn-auth.conf
# /usr/local/apache2.2.21/bin/htpasswd -cm /data/svn/svn-auth.conf tonyty163
New password:
Re-type new password:
Adding password for user tonyty163
注:只有第一次需要加-c參數,後期再添加用戶千萬不能加-c,否則會將原文件覆蓋的,如下:
# /usr/local/apache2.2.21/bin/htpasswd -m /data/svn/svn-auth.conf admin
New password:
Re-type new password:
Adding password for user admin

配置svn權限控制文件svn-access.conf
[groups]
admin = admin, tonyty163
developers = tonyty163

# Default access rule for ALL repositories
# Everyone can read, admins can write, tonyty163 is excluded.
[/]
* = r
@admin = rw
tonyty163 =

# Allow developers complete access to their project repos
[project1:/]
@developers = rw

# Give the doc people write access to all the docs folders
[/trunk/doc]
@developer = rw

# Give trainees write access in the training repository only
[TrainingRepos:/]
@training = rw

權限控制文件裏面要把握3個核心概念
1、[]中的內容
這裡面的內容主要包括幾個分類,如本例中:
組[group],庫[repositories:/],目錄[/trunk/doc]
2、用戶
如本例中的:admin, tonyty163
注:用戶可以直接定義,以svn-auth.conf裏的用戶為准,不是一定要加入組的
3、權限
r讀,W寫
一般常用的也就這兩種,其他的目前也沒用過


2、配置apache

# vi /usr/local/apache2.2.21/conf/httpd.conf
查找LoadModule
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so

並在配置文件最後添加
<Location /svn>
DAV svn
SVNParentPath /data/svn
AuthType Basic
AuthName "Subversion repository"
AuthUserFile /data/svn/svn-auth.conf
Require valid-user
AuthzSVNAccessFile /data/svn/svn-access.conf
</Location>
配置詳解

AuthUserFile /data/svn/svn-auth.conf指定的是SVN訪問帳號密碼文件
AuthzSVNAccessFile /data/svn/svn-access.conf指定的是SVN的訪問控制文件

七、新建第一個庫
# svnadmin create /data/svn/project1
在瀏覽器中輸入http://IP/svn/project1如果輸出
project1 - Revision 0: /
即表示成功

八、排錯
當配置完成,在瀏覽器中輸入http://IP/svn/會出現
403 Forbbident
這裡需要注意,必須要建立庫,並且訪問到該庫才行,如:
http://IP/svn/project1