CentOS 6下源码安装SVN服务

技术 秋水逸冰 5206 次围观 5 次吐槽

SVN

  最近在折腾SVN的安装和配置。尽管Google Code已经有完美的4GB空间的SVN服务,Git也有完善的Git工具,但有时候需要搭建一个私人的版本库。
  SVN其实就是Subversion,分为服务器端和客户端。本次折腾是记录在服务器端的安装过程。

系统环境说明如下:

操作系统:        Centos6.4 x86
SVN:             subversion-1.8.0
Apache:          httpd-2.4.6

如开启防火墙,则需添加如下列的规则以放行svn的3690端口

iptables -A INPUT -p tcp --dport 3690 -j ACCEPT
iptables save

检查是否安装了低版本的SVN

rpm -qa | grep subversion

一般返回的默认版本:

subversion-1.6.11-9.el6_4.i686

卸载旧版本SVN

yum remove subversion

下载、编译、安装的步骤

1、编译安装httpd-2.4.6

下载并解压依赖包apr-1.4.8、apr-util-1.5.2

wget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.4.8.tar.gz
wget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.5.2.tar.gz
tar -zxf apr-1.4.8.tar.gz
tar -zxf apr-util-1.5.2.tar.gz

下载并解压httpd-2.4.6

wget http://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.6.tar.gz
tar -zxf httpd-2.4.6.tar.gz

移动apr-1.4.8、apr-util-1.5.2到httpd-2.4.6的srclib目录下

mv apr-1.4.8 httpd-2.4.6/srclib/apr
mv apr-util-1.5.2 httpd-2.4.6/srclib/apr-util

编译httpd-2.4.6

cd httpd-2.4.6
./configure --prefix=/usr/local/apache --enable-so --enable-dav --enable-deflate=shared --enable-ssl=shared --enable-expires=shared  --enable-headers=shared --enable-rewrite=shared --enable-static-support  --with-included-apr --enable-modules=all --enable-mods-shared=all --with-mpm=prefork
make && make install

2、编译安装subversion-1.8.0

编译安装sqlite3.7.17

wget http://www.sqlite.org/2013/sqlite-autoconf-3071700.tar.gz
tar -zxf sqlite-autoconf-3071700.tar.gz
cd sqlite-autoconf-3071700
./configure
make && make install

下载svn源码包并安装

wget http://mirrors.tuna.tsinghua.edu.cn/apache/subversion/subversion-1.8.0.tar.gz
tar -zxf subversion-1.8.0.tar.gz
cd subversion-1.8.0
./configure --with-apr=/usr/local/apache --with-apr-util=/usr/local/apache --with-sqlite=/usr/local
make && make install 

检查安装是否成功

svnserve --version

返回值:

svnserve, version 1.8.0 (r1490375)
   compiled Jul 23 2013, 21:32:09 on i686-pc-linux-gnu
Copyright (C) 2013 The Apache Software Foundation.
This software consists of contributions made by many people;
see the NOTICE file for more information.
Subversion is open source software, see http://subversion.apache.org/

The following repository back-end (FS) modules are available:
* fs_fs : Module for working with a plain file (FSFS) repository.
Cyrus SASL authentication is available.

代码库创建

mkdir -p /opt/svn/repositories
svnadmin create /opt/svn/repositories

执行上面的命令后,自动建立repositories库,查看/opt/svn/repositories 文件夹发现包含了conf,db,format,hooks,locks, README.txt等文件,说明一个SVN库建立完成。

配置代码库
进入上面生成的文件夹conf下,进行配置 

cd /opt/svn/repositories/conf

用户密码passwd配置

vi passwd

passwd文件的内容如下:

### This file is an example password file for svnserve.
### Its format is similar to that of svnserve.conf. As shown in the
### example below it contains one section labelled [users].
### The name and password for each user follow, one account per line.

[users]
# harry = harryssecret
# sally = sallyssecret
test = 123456789

权限控制authz配置

vi authz

目的是设置哪些用户可以访问哪些目录,authz文件的内容如下:

### This file is an example authorization file for svnserve.
### Its format is identical to that of mod_authz_svn authorization
### files.
### As shown below each section defines authorizations for the path and
### (optional) repository specified by the section name.
### The authorizations follow. An authorization line can refer to:
###  - a single user,
###  - a group of users defined in a special [groups] section,
###  - an alias defined in a special [aliases] section,
###  - all authenticated users, using the '$authenticated' token,
###  - only anonymous users, using the '$anonymous' token,
###  - anyone, using the '*' wildcard.
###
### A match can be inverted by prefixing the rule with '~'. Rules can
### grant read ('r') access, read-write ('rw') access, or no access
### ('').

[aliases]
# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average

[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe

# [/foo/bar]
# harry = rw
# &joe = r
# * =

# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r

[/]
test = rw

设置[/]代表根目录下所有的资源 

服务svnserve.conf配置

vi svnserve.conf

svnserve.conf文件的内容如下:

[general]
#匿名访问的权限,可以是read,write,none,默认为read
anon-access=none
#使授权用户有写权限 
auth-access=write
#密码数据库的路径 
password-db=passwd
#访问控制文件 
authz-db=authz
#认证命名空间,subversion会在认证提示里显示,并且作为凭证缓存的关键字 
realm=/opt/svn/repositories

启动svn服务

svnserve -d -r /opt/svn/repositories

查看SVN进程

ps -ef|grep svn|grep -v grep

返回

root     20850     1  0 Jul24 ?        00:00:00 svnserve -d -r /opt/svn/repositories

查看SVN监听的端口

netstat -ln |grep 3690

停止启动SVN

killall svnserve    #停止 
svnserve -d -r /opt/svn/repositories  #启动

目前最流行的svn客户端非TortoiseSVN莫属
下载安装

http://sourceforge.net/projects/tortoisesvn/files/latest/download?source=dlp

客户端连接地址:svn://公网或内网的IP地址
用户名/密码: test/123456789

参考链接:
http://subversion.apache.org/
http://www.sqlite.org/download.html
http://showerlee.blog.51cto.com/2047005/1240955
http://cwind.blog.51cto.com/62582/1133189
http://www.cnblogs.com/zhoulf/archive/2013/02/02/2889949.html

转载请注明:秋水逸冰 » CentOS 6下源码安装SVN服务

发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

网友最新评论 (5)

  1. 没有看到 svn和apache的结合的地方啊?
    野火冷魂3年前 (2016-04-18)回复
  2. 不错,挺好的。谢谢
    望窗秋水6年前 (2013-10-30)回复
  3. 不错,帮助很大,谢谢分享。
    我有绣春刀6年前 (2013-10-15)回复
  4. 谷歌搜索:优化 httpd-2.4.6.tar.gz 到你这了,我搜SVN+Apache你为何不出来? 写的深度不是很深,却很实用,感谢
    凯斯6年前 (2013-08-29)回复
    • 这是Google的事,我没有可以优化过关键字。也没SEO过。:) 我记录的是自己折腾的过程,对访客有帮助也会感到开心。
      秋水逸冰6年前 (2013-08-29)回复