安装环境:
OS: RedHat Linux 9
需要软件,google很容易搜索到:
SVN: Subversion 1.5.1
HTTPD: Apache Httpd 2.2.9
APR: Apache Apr 1.3.3
APU: Apache Apr-Util 1.3.4
1. 下载源代码:
到各自的官方网站下载相应的源代码的tar.bz2包,解包后准备编译安装:
2. 编译源代码:
按下面的顺序编译源代码:
(1) Apache Apr
# tar jxvf apr-1.3.3.tar.bz2
# cd apr-1.3.3
# ./configure --prefix=/usr/local/apr
# make
# make install
(2) Apache Apr-Util
# tar jxvf apr-util-1.3.4.tar.bz2
# cd apr-util-1.3.4
# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
# make
# make install
(3) Apache Httpd
# tar jxvf httpd-2.2.9.tar.bz2
# cd httpd-2.2.9
# ./configure --prefix=/usr/local/apache2 --enable-dav --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
# make
# make install
(4) Subversion
# tar jxvf subversion-1.5.1.tar.bz2
# cd subversion-1.5.1
#
./configure --prefix=/usr/local/subversion
--with-apxs=/usr/local/apache2/bin/apxs --with-apr=/usr/local/apr
--with-apr-util=/usr/local/apr-util
# make
# make install
以上的编译通常情况都能顺利编译成功,得到相应的可执行程序。
检查WebDav for SVN 模块:
# cd /usr/local/apache2/modules
检查 mod_dav_svn.so 和 mod_authz_svn.so,如果上述第2步编译成功,这两个模块应该可以看到。
3. 创建svn用户:
# groupadd svn
# useradd -g svn svn
# passwd svn
以后代码库的创建维护等,都用这个帐户来操作。
4. 创建版本库:
以svn用户登录
准备环境变量:
$ SVN_HOME=/usr/local/subversion
$ export SVN_HOME
$ PATH=$PATH:$SVN_HOME/bin
$ export PATH
上述命令创建了版本库sandbox,用于测试:
$ svnadmin create --fs-type fsfs sandbox
还可以再创建工程的版本库:
$ svnadmin create --fs-type fsfs projects
创建启动Subversion的脚本:
$ echo '/usr/local/subversion/bin/svnserve -d -r /home/svn/' > startup.sh
$ chmod +x startup.sh
$ ./startup.sh
将启动脚本放置到开机自动启动脚本中:
以root身份修改文件:/etc/rc.d/rc.local,添加以下文字:
su -c /home/svn/startup.sh svn
5. 配置Apache Httpd
# cd /usr/local/apache2/conf
# vi httpd.conf
加载WebDav for SVN模块:
#
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l') do not need
# to be loaded here.
#
# Example:
# LoadModule foo_module modules/mod_foo.so
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
添加最后两行(默认编译后,configure会自动加上):
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
修改启动httpd的默认用户:
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
#User daemon
#Group daemon
User svn
Group svn
将执行httpd的用户和组设为svn,这样做是为了让httpd进程能访问版本库的数据。
在Apache Http Server里配置虚拟主机:
将httpd.conf中的虚拟主机的注释去掉,然后编辑/usr/local/apache2/conf/extra/httpd-vhost.conf。
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
添加虚拟主机svn.yourcompany.com,当然,这个主机名需要使用你自己的域名。
# vi /usr/local/apache2/conf/extra/httpd-vhost.conf
ServerAdmin
ServerName svn.yourcompany.com
ErrorLog logs/svn.yourcompany.com-error_log
CustomLog logs/svn.yourcompany.com-access_log common
DAV svn
SVNListParentPath on
SVNParentPath /home/svn
这样配置的目的是可以使用 或 这样的URL来供各种客户端通过http协议访问该版本库中的文件。
6. 用户认证和授权
用户认证是为了验证访问SVN的用户身份,授权是为了约束用户的权限,约束用户读写每个目录或文件的权限,请参阅SVN相关的文档。通过http协议的认证和通过svn协议的认证略
有不同,需要注意。
阅读(1907) | 评论(0) | 转发(0) |