SVN Server安装部署攻略(Linux+SubVersion+Apache)

一.  安装apr依赖库(Apache Portable Runtime Module)

http://apache.mirror.phpchina.com/apr/apr-1.2.11.tar.gz

./configure

make

make install

http://apache.mirror.phpchina.com/apr/apr-util-1.2.10.tar.gz

./configure --with-apr=/home/chenmin/apr-1.2.11

make

make install

二. 重新编译httpd

检查已安装的 Apache2 是否已经安装了 mod_dav .

如 果已经成功安装了Apache,使用 httpd -M 来查看有没有安装 dav_module,如果没有的话 必须附加 ‘–enable-dav’ ‘–enable-dav-fs’ 两个参数重新编译 Apache,否则即使编译通过了svn,apache也会启动不起来.

wget http://apache.mirror.phpchina.com/httpd/httpd-2.2.6.tar.gz

./configure --enable-dav --enable-dav-fs

make

make install

三. 安装subversion

最新的版本 Subversion 可以在这里找到 :http://subversion.tigris.org/project_packages.html

http://subversion.tigris.org/downloads/subversion-1.4.5.tar.gz

下载neon库,使svn支持webdav, https加密的链接.

下载之后放到subversion安装目录下,并重命名即可, subversion会自动监测并配置, 目前只支持 0.25.5.

;cd subversion-SVN-LAST-VERSION-DIR 

cd subversion-1.4.5

wget http://www.webdav.org/neon/neon-0.25.5.tar.gz

tar xzf neon-0.25.5.tar.gz

mv neon-0.25.5 neon

./configure --with-apxs=/usr/local/apache2/bin/apxs --with-apr=/home/chenmin/apr-1.2.11 --with-apr-util=/home/chenmin/apr-util-1.2.10 --with-ssl

由于没有安装Berkeley DB,所以使用FSFS

make

sudo make install

四.  配置subversion和apache

拷贝svn模块到apache模块目录下

cp /data/subversion-1.4.5/subversion/mod_dav_svn/.libs/mod_dav_svn.so /usr/local/apache2/modules/

cp /data/subversion-1.4.5/subversion/mod_authz_svn/.libs/mod_authz_svn.so /usr/local/apache2/modules/

编辑httpd.conf

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

</Location>

运行htpasswd添加用户和密码

/usr/local/apache2/bin/htpasswd -cm /data/svn/svn-auth-file chenmin

/usr/local/apache2/bin/htpasswd -m /data/svn/svn-auth-file admin

再次编辑httpd.conf

<Location /svn>

DAV svn

SVNParentPath /data/svn

AuthType Basic

AuthName "Subversion repository"

AuthUserFile /data/svn/svn-auth-file

Require valid-user

AuthzSVNAccessFile /data/svn/svn-access-file

</Location>

其中svn-auth-file是认证文件,存储用户名和密码,svn-access-file是访问权限文件,规定各个目录的访问者的权限, 示例的权限分配的文件的格式如下。

[groups]

admin = john, kate

devteam1 = john, rachel, sally

devteam2 = kate, peter, mark

docs = bob, jane, mike

training = zak

# Default access rule for ALL repositories

# Everyone can read, admins can write, Dan German is excluded.

[/]

* = r

@admin = rw

dangerman =

# Allow developers complete access to their project repos

[proj1:/]

@devteam1 = rw

[proj2:/]

@devteam2 = rw

[bigproj:/]

@devteam1 = rw

@devteam2 = rw

trevor = rw

# Give the doc people write access to all the docs folders

[/trunk/doc]

@docs = rw

# Give trainees write access in the training repository only

[TrainingRepos:/]

@training = rw

权限配置文件中,关键的几个概念是:目标和权限,也就是为谁分配什么样的权限。读为r,写为w,如果没有权限那么什么也不写即可。

=====================================================================================

apache的编译指令

cd /usr/local/src/httpd-2.2.19

./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr1/bin/apr-1-config --with-apr-util=/usr/local/apr-util/bin/apu-1-config --enable-so --enable-dav --enable-dav-fs --enable-maintainer-mode --enable-rewrite

=====================================================================================

subversion的编译指令

./configure --with-apxs=/usr/local/apache/bin/apxs --with-apr=/usr/local/apr1/bin/apr-1-config --with-apr-util=/usr/local/apr-util/bin/apu-1-config --with-ssl --enable-shared --prefix=/usr/local/subversion

#--enable-shared 64位系统下需要添加

=====================================================================================

需要特别注意的就是权限问题:

在conf/httpd.conf中指定了运行apache的用户和组,需要为svn所在的路径指定相应的权限,不然会出现权限(permission)问题。

====================遇到的问题=================

1.  编译subversion时出现少expat库

    下载expat-2.0.0.tar.gz安装即可

2.  在安装subversion时,make没问题,make install时出现

    libexpat.so.1:cannot open shared object file: No such file or directory

    意思是找不到Libexpat.so.1这个文件

    运行whereis libexpat.so.1

    解决:vi /etc/ld.so.conf

    加入libexpat.so.1的目录/usr/local/lib保存退出

    运行ldconfig

3.  安装好了后,浏览器打开http://xxx/svn,登录出现不了页面,出现

    <D:error><C:error><m:human-readable errcode="2">....

    解决:这是httpd.conf里面的<Location svn>中svnpath只想错误没指到创建的资料库。

============================创建svn资料库======================================

svnadmin -h

============================启动svn服务器====================================

svnserve -h

猜你喜欢

转载自haiker.iteye.com/blog/1127284