设为首页 收藏本站
查看: 895|回复: 0

[经验分享] CentOS 5.5下搭建部署独立SVN服务器全程详解

[复制链接]

尚未签到

发表于 2016-5-13 11:11:01 | 显示全部楼层 |阅读模式
  SVN服务器有2种运行方式:


1、独立服务器 (例如:svn://xxx.com/xxx);

2、借助apache   (例如
http://svn.xxx.com/xxx);

为了不依赖apache,我选择第一种方式:独立的svn服务器。
SVN存储版本数据也有2种方式:

1、bdb;

2、fsfs。

由于bdb方式在服务器中断时,有可能锁住数据,所以还是fsfs方式更安全一点,我也选择这种方式。
具体部署:

1.下载subversion安装包



  [iyunv@server ~]# cd /usr/local/src

[iyunv@server src]# ls

[iyunv@server src]#

wget http://subversion.tigris.org/downloads/subversion-1.6.6.tar.gz

[iyunv@server src]# wget http://subversion.tigris.org/downloads/subversion-deps-1.6.6.tar.gz


[
root@server src]# tar xfvz subversion-1.6.6.tar.gz

[iyunv@server src]# tar xfvz subversion-deps-1.6.6.tar.gz

[iyunv@server src]# cd subversion-1.6.6

[iyunv@server subversion-1.6.6]#



  
2.编译SVN

首先检测系统有没有安装SSL:



[iyunv@server subversion-1.6.6]# find / -name opensslv.h

[iyunv@server subversion-1.6.6]#

  
找不到,就执行如下命令进行安装:



[iyunv@server subversion-1.6.6]# yum install openssl

[iyunv@server subversion-1.6.6]# yum install openssl-devel

 
  
安装之后用find / -name opensslv.h命令找到opensslv.h所在的目录,即下列--with-openssl=后面的路径,编译:


[iyunv@server subversion-1.6.6]# find / -name opensslv.h

/usr/include/openssl/opensslv.h


[iyunv@server subversion-1.6.6]#
./configure --prefix=/usr/local/svn --with-openssl=/usr/include/openssl --without-berkeley-db
  
注:以svnserve方式运行,不加apache编译参数。以fsfs格式存储版本库,不编译berkeley-db。

此时编译报如下错误:


configure: WARNING: unrecognized options: --with-openssl

configure: Configuring Subversion 1.6.6

configure: creating config.nice

checking for gcc... no

checking for cc... no

checking for cl.exe... no

configure: error: in `/usr/local/src/subversion-1.6.6':

configure: error: no acceptable C compiler found in $PATH

See `config.log' for more details.

  
说明没有安装gcc相关库,使用如下命令安装gcc后再编译:


[iyunv@server subversion-1.6.6]# yum -y install gcc

[iyunv@server subversion-1.6.6]# ./configure --prefix=/usr/local/svn --with-openssl=/usr/include/openssl --without-berkeley-db

 
  
最后出现下面WARNING,直接忽略即可,因为不使用BDB存储。



configure: WARNING: we have configured without BDB filesystem support

You don't seem to have Berkeley DB version 4.0.14 or newer

installed and linked to APR-UTIL. We have created Makefiles which

will build without the Berkeley DB back-end; your repositories will

use FSFS as the default back-end. You can find the latest version of

Berkeley DB here:
http://www.sleepycat.com/download/index.shtml
 

  
3.安装SVN


为避免出现以下错误


error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such file or directory
  
先执行以下操作:

1)、编辑/etc/ld.so.conf文件,添加下面一行:


/usr/local/lib
  
2)、保存后运行ldconfig:


/sbin/ldconfig
  注:ld.so.conf和ldconfig用于维护系统动态链接库。
安装





[iyunv@server subversion-1.6.6]# make && make install
  安装完成,执行以下命令测试:




  [iyunv@server subversion-1.6.6]# /usr/local/svn/bin/svnserve --version


svnserve,版本 1.6.6 (r40053)

   编译于 Feb 15 2012,22:15:26


  版权所有 (C) 2000-2009 CollabNet。

Subversion 是开放源代码软件,请参阅 http://subversion.tigris.org/
站点。

此产品包含由 CollabNet(http://www.Collab.Net/
) 开发的软件。


  下列版本库后端(FS) 模块可用:

  * fs_fs : 模块与文本文件(FSFS)版本库一起工作。


  为了方便下操作,下面将SVN的BIN添加到PATH,编辑/etc/profile,添加:


PATH=/usr/local/svn/bin:$PATH
  
保存后,使其立即生效:


source /etc/profile
  
4.配置SVN

建立版本库目录,可建多个:

  [iyunv@server ~]# mkdir -p /home/svndata/repos       #建立版本库

[iyunv@server ~]# /usr/local/svn/bin/svnadmin create /home/svndata/repos       #修改版本库配置文件 


  
编辑/home/svndata/repos/conf/svnserve.conf,内容修改为:


[general]

anon-access = none

auth-access = write

password-db = /usr/local/svn/conf/passwd.conf

authz-db = /usr/local/svn/conf/authz.conf

realm = repos 

  
注意:对用户配置文件的修改立即生效,不必重启svn。

在/usr/local/svn/下面新建conf目录,并在/usr/local/svn/conf内新建passwd.conf和authz.conf文件:

  mkdir conf

cd conf/


touch passwd.conf

touch authz.conf



  
添加用户及密码:


  [iyunv@server ~]# useradd wll

[iyunv@server ~]# passwd wll


  
编辑/usr/local/svn/conf/passwd.conf,添加如下代码并保存:


[users]

wll = 123456

  
配置svn用户访问权限,编辑usr/local/svn/conf/authz.conf,添加如下代码并保存:

  [groups]

admin = wll

[/]

@admin = rw

# [repos:/abc/aaa]

# king = rw

# [repos:/pass]

# king =svn


  注意:

* 权限配置文件中出现的用户名必须已在用户配置文件中定义。

* 对权限配置文件的修改立即生效,不必重启svn。

用户组格式:

[groups]

= ,

其中,1个用户组可以包含1个或多个用户,用户间以逗号分隔。

版本库目录格式:

[<版本库>:/项目/目录]

@<用户组名> = <权限>

<用户名> = <权限>

其中,方框号内部分可以有多种写法:

[/],表示根目录及以下,根目录是svnserve启动时指定的,我们指定为/home/svndata,[/]就是表示对全部版本库设置权限。

[repos:/] 表示对版本库repos设置权限;

[repos:/abc] 表示对版本库repos中的abc项目设置权限;

[repos:/abc/aaa] 表示对版本库repos中的abc项目的aaa目录设置权限;

权限主体可以是用户组、用户或*,用户组在前面加@,*表示全部用户。

权限可以是w、r、wr和空,空表示没有任何权限。


  
建立启动svn的用户:  



[iyunv@server ~]# useradd svn

[iyunv@server ~]# passwd svn

  
允许用户svn访问版本库:



[iyunv@server ~]# chown -R svn:svn /home/svndata 
  
启动svn:


  [iyunv@
server ~]# su - svn -c "svnserve -d --listen-port 9999 -r /home/svndata"

  其中:

su - svn :表示以用户svn的身份启动svn;

-d :表示以daemon方式(后台运行)运行;

--listen-port 9999 :表示使用9999端口,可以换成你需要的端口。但注意,使用1024以下的端口需要root权限;

-r /home/svndata :指定根目录是/home/svndata。



  
5.将svn加入到开机启动

编辑/etc/rc.d/rc.local文件,加入如下启动命令:



/usr/local/svn/bin/svnserve -d --listen-port 9999 -r /home/svndata
  
如果想停止svn,则使用如下命令:


killall svnserve
  
如果想将svn作为服务,在/etc/rc.d/init.d/目录下新建名为svn的文件并设置权限为755,并添加如下代码:



#!/bin/bash

# build this file in /etc/rc.d/init.d/svn

# chmod 755 /etc/rc.d/init.d/svn

# centos下可以用如下命令管理svn: service svn start(restart/stop)

SVN_HOME=/home/svndata

if [ ! -f "/usr/local/svn/bin/svnserve" ]

then

    echo "svnserver startup: cannot start"

    exit

fi

case "$1" in

    start)

        echo "Starting svnserve..."

        /usr/local/svn/bin/svnserve -d --listen-port 9999 -r $SVN_HOME

        echo "Finished!"

        ;;

    stop)

        echo "Stoping svnserve..."

        killall svnserve

        echo "Finished!"

        ;;

    restart)

        $0 stop

        $0 start

        ;;

    *)

        echo "Usage: svn { start | stop | restart } "

        exit 1

esac 

  
6.连接SVN

安装TortoiseSVN,重启系统。启动TortoiseSVN并在地址栏中输入

  svn://192.168.1.87:9999/repos



根据提示输入用户名与密码后就可以


  
  

原始出处 :http://300second.blog.iyunv.com/7582/780348
 

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-216480-1-1.html 上篇帖子: 在Fedora14上(或CentOS 5.5上)安装oracle 10g 下篇帖子: CentOS 6.2下安装基于Suricata + Barnyard 2 + Base的入侵检测系统
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表