Subversion 1.4.3 + Apache 2.2.4 for Linux 安装
经过几天努力,终于把Subversion + Apache在Linux上安装成功,能顺利地通过http协议和svn协议访问版本库了,这里和大家分享。
安装环境:
OS: RedHat AdvanceServer 4 Update 4
需要软件:
SVN: Subversion 1.4.3
HTTPD: Apache Httpd 2.2.4
APR: Apache Apr 1.2.8
APU: Apache Apr-Util 1.2.8
1. 下载源代码:
到各自的官方网站下载相应的源代码的tar.gz包,解包后准备编译安装:
2. 编译源代码:
按下面的顺序编译源代码:
(1) Apache Apr
# cd apr-1.2.8
# ./configure --prefix=/usr/local/apr
# make
# make install
(2) Apache Apr-Util
# cd apr-util-1.2.8
# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
# make
# make install
(3) Apache Httpd
# cd httpd-2.2.4
# ./configure --prefix=/usr/local/apache2 --enable-dav --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
# make
# make install
(4) Subversion
# cd subversion-1.4.3
# ./configure --prefix=/usr/local/subversion --with-apxs=/usr/local/apache2/bin/apxs
# 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
以后代码库的创建维护等,都用这个帐户来操作。
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模块:
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
添加最后两行(默认编译后,configure会自动加上):
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
修改启动httpd的默认用户:
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
将执行httpd的用户和组设为svn,这样做是为了让httpd进程能访问版本库的数据。
在Apache Http Server里配置虚拟主机:
将httpd.conf中的虚拟主机的注释去掉,然后编辑/usr/local/apache2/conf/extra/httpd-vhost.conf。
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
添加虚拟主机svn.yourcompany.com,当然,这个主机名需要使用你自己的域名。
# vi /usr/local/apache2/conf/extra/httpd-vhost.conf
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
这样配置的目的是可以使用 http://svn.yourcompany.com/sandbox 或 http://svn.yourcompany.com/projects 这样的URL来供各种客户端通过http协议访问该版本库中的文件。
6. 用户认证和授权
用户认证是为了验证访问SVN的用户身份,授权是为了约束用户的权限,约束用户读写每个目录或文件的权限,请参阅SVN相关的文档。通过http协议的认证和通过svn协议的认证略有不同,需要注意。