SVN服务器搭建(与apache整合)

一.SVN介绍

SVN是一个版本控制工具,Subversion的版本库(repository),就是位于服务器,统一管理和储存数据的地方。

二.SVN数据存储方式

在Subversion中,版本库的数据存储有两种方式:一种是在Berkeley DB数据库中存放数据;另一种是普通文件,采用自定义的格式来存储,称为FSFS。

三.SVN搭建

1.所需软件包

httpd-2.2.27.tar.gz

apr-1.5.1.tar.gz

apr-util-1.5.3.tar.gz

sqlite-amalgamation-3.6.17.tar.gz

subversion-1.8.10.tar.gz

2.安装软件包

2.1 安装apache

# tar zxf httpd-2.2.27.tar.gz

# cd httpd-2.2.27

# ./configure --prefix=/app/sinova/apache --enable-dav --enable-so --enable-modules=most

# make

# make install

2.2 安装apr、apr-util

# tar zxf apr-1.5.1.tar.gz

# cd apr-1.5.1

# ./buildconf   #验证系统是否已经安装python、autoconf、libtool,如果没有安装,使用yum或rpm方式安装相应包即可。

验证正确的如下:

# ./configure --prefix=/usr/local/apr

# make

# make install

# tar zxf apr-util-1.5.3.tar.gz

# cd apr-util-1.5.3

# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

# make

# make install

2.3 安装sqlite

# tar zxf sqlite-amalgamation-3.6.17.tar.gz

# cd sqlite -3.6.17

# ./configure --prefix=/usr/local/sqlite

# make

# make install

2.4 安装svn

# tar zxf subversion-1.8.10.tar.gz

# cd subversion-1.8.10

# ./configure --prefix=/app/svn --with-apxs=/app/sinova/apache/bin/apxs --with-apr=/usr/local/apr/bin/apr-1-config --with-apr-util=/usr/local/apr-util/bin/apu-1-config --with-sqlite=/usr/local/sqlite/ --with-openssl --with-zlib --enable-maintainer-mod

# make

# make install

 

configure时遇到错误:

get the sqlite 3.7.15.1 amalgamation from:

    http://www.sqlite.org/sqlite-amalgamation-3071501.zip

unpack the archive using unzip and rename the resulting

directory to:

/app/soft/subversion-1.8.10/sqlite-amalgamation

configure: error: Subversion requires SQLite

 

解决办法:

如果服务器不能联网,下载http://www.sqlite.org/sqlite-amalgamation-3071501.zip,然后上传至服务器。解压

# unzip sqlite-amalgamation-3071501.zip 

# cp sqlite-amalgamation-3071501/* /app/soft/sqlite -3.6.17/

然后重新安装sqlite后再configure。

 

四. 配置SVN与apache

1.创建svn项目仓库

# mkdir /app/svnroot/ltzb    #创建svn根目录

# /app/svn/bin/svnadmin create /app/svnroot/ltzb/test

2.创建权限配置文件

# vi /app/svnroot/ltzb/authz.conf  #添加如下内容

[/]   

* = r   #表示对所有的用户开放读的权限

[test:/]

Eivll0m = rw  #表示用户liyizhen对仓库test有读写权限。

3.创建用户认证文件

# /app/sinova/apache/bin/htpasswd -c /app/svnroot/ltzb/authfile Eivll0m

4.svn安装完成后,会在/app/svn/libexec目录下产生mod_authz_svn.so和mod_dav_svn.so这两个模块,将这两个模块文件拷到apache模块目录下。

# cp /app/svn/libexec/* /app/sinova/apache/modules/   #设置到权限问题使用root用户来操作,然后赋权给相应用户。

5.编辑httpd.conf文件,修改如下内容:

User sinova     #修改

Group sinova    #修改

ServerName www.example.com:80    #去掉本行前面的注释

LoadModule dav_svn_module     modules/mod_dav_svn.so   #添加

LoadModule authz_svn_module   modules/mod_authz_svn.so  #添加

以下内容在最后添加:

<Location /ltzb>

DAV svn

SVNParentPath "/app/svnroot/ltzb"

AuthzSVNAccessFile "/app/svnroot/ltzb/authz.conf"

AuthType Basic

AuthName "Subversion.zoneyump"

AuthUserFile "/app/svnroot/ltzb/authfile"

Require valid-user

</location>

 6.启动apache,关闭iptables,selinux等

# sudo /app/sinova/apache/bin/apachectl start

五.使用SVN客户端测试

1.通过浏览器访问svn,在地址栏中输入http://192.168.0.105/ltzb/test

2.通过windows下的TortoiseSVN客户端

在E盘或其它盘中新建一个目录test(名称自定),进入该目录,鼠标右键选择SVN cheakout...

使用此客户上传遇到的错误:SVN Can’t open file ‘/home/svn/db/txn-current-lock’错误

解决方法:

chmod –R o+rw /app/svnroot/ltzb/test

原文地址:https://www.cnblogs.com/Eivll0m/p/4622745.html