@52fhy
2015-11-28T04:48:44.000000Z
字数 4884
阅读 565
Linux
yum方式安装比较简单。重点是配置。默认安装会包含客户端。
yum install -y subversion
等待一会儿,显示下边的内容:
#省略部分内容Total 982 kB/s | 2.5 MB 00:02Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning TransactionInstalling : perl-URI-1.40-2.el6.noarch 1/7Installing : libproxy-bin-0.3.0-10.el6.i686 2/7Installing : libproxy-python-0.3.0-10.el6.i686 3/7Installing : libproxy-0.3.0-10.el6.i686 4/7Installing : pakchois-0.4-3.2.el6.i686 5/7Installing : neon-0.29.3-3.el6_4.i686 6/7Installing : subversion-1.6.11-15.el6_7.i686 7/7Installed:subversion.i686 0:1.6.11-15.el6_7Dependency Installed:libproxy.i686 0:0.3.0-10.el6 libproxy-bin.i686 0:0.3.0-10.el6 libproxy-python.i686 0:0.3.0-10.el6 neon.i686 0:0.29.3-3.el6_4pakchois.i686 0:0.4-3.2.el6 perl-URI.noarch 0:1.40-2.el6Complete!
svnserve --version
这是我的显示内容:
svnserve,版本 1.6.11 (r934486)编译于 Aug 17 2015,08:21:51版权所有 (C) 2000-2009 CollabNet。Subversion 是开放源代码软件,请参阅 http://subversion.tigris.org/ 站点。此产品包含由 CollabNet(http://www.Collab.Net/) 开发的软件。下列版本库后端(FS) 模块可用:* fs_base : 模块只能操作BDB版本库。* fs_fs : 模块与文本文件(FSFS)版本库一起工作。Cyrus SASL 认证可用。
mkdir /data/svn #我这里把版本库放在了data目录下的svn文件夹,方便管理svnadmin create /data/svn/repo#我这里将svn作为所有版本库的目录,并创建了一个名为repo的版本库。创建其它版本库与此类似。
创建版本库后,在当前版本库目录中会生成下面的文件,其中我们关心的是配置文件。
[root@localhost ~]cd /data/svn/repo/[root@localhost repo]# lsconf db format hooks locks README.txt[root@localhost repo]# cd conf[root@localhost conf]# ls -a. .. authz passwd svnserve.conf说明:(1)svnserve.conf: svn服务综合配置文件。(2)passwd: 用户名口令文件。(3)authz: 权限配置文件。
### 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 = sallyssecretuser1 = passwd1user2=passwd2#其中对应的是 用户名=密码 ,其中等号两边的空格不是必须的。
[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#将上面创建的分成两个组,组键名、键值自定义:team0=user1team1=user2# [/foo/bar]# harry = rw# &joe = r #上面的别名定义在这里实现 &在这里理解为指针就很容易了# * =# [repository:/baz/fuz]# @harry_and_sally = rw# * = r[repo:/]@team0=r@team1=rw# 第一个小组只有读取的权限,第二个小组有读写的权限# 单个版本库的权限配置在这个文件中实现
vim svnserve.conf
[general]### These options control access to the repository for unauthenticated### and authenticated users. Valid values are "write", "read",### and "none". The sample settings below are the defaults.anon-access = none #没有登录的用户不能访问auth-access = write #登录的用户可以写入### The password-db option controls the location of the password### database file. Unless you specify a path starting with a /,### the file's location is relative to the directory containing### this configuration file.### If SASL is enabled (see below), this file will NOT be used.### Uncomment the line below to use the default password file.password-db = passwd #密码文件为当前目录下的passwd,建议多个版本库的话统一配置在某个公共目录里,如/svn/conf/passwd### The authz-db option controls the location of the authorization### rules for path-based access control. Unless you specify a path### starting with a /, the file's location is relative to the the### directory containing this file. If you don't specify an### authz-db, no path-based access control is done.### Uncomment the line below to use the default authorization file.authz-db = authz #验证文件为当前目录下的authz,建议多个版本库的话统一配置在某个公共目录里,如/svn/conf/authz
svnserve -d -r /data/svn/
ps -aux |grep svnkill -9 进程id
$ mkdir MyProject$ mkdir MyProject/trunk$ mkdir MyProject/branches$ mkdir MyProject/tagssvn import MyProject svn://192.168.12.2/repo/MyProject -m "first import project"
svn co svn://192.168.12.3/repo/MyProject
8.1 svn服务自启动脚本
把脚本放在/etc/init.d/下
vi /etc/rc.d/init.d/svn
svn脚本内容:
#!/bin/bash# chkconfig: - 85 15# description: svn serverSVN_HOME=/data/svnif [ ! -f "/usr/bin/svnserve" ]thenecho "svnserver startup: cannot start"exitficase "$1" instart)echo "Starting svnserve…"/usr/bin/svnserve -d --listen-port 3690 -r $SVN_HOMEecho "Finished!";;stop)echo "Stoping svnserve…"killall svnserveecho "Finished!";;restart)$0 stop$0 start;;*)echo "Usage: svn { start | stop | restart } "exit 1esac
这里请注意,不要删除# chkconfig: - 85 15和# description: svn server,不然无法使用chkconfig加入服务,会提示service svn does not support chkconfig.
然后执行
chmod 755 /etc/init.d/svnchkconfig --add svnchkconfig svn on
最后查看下chkconfig --list|grep svn
可以看到svn已经加入到服务中,并已经在2345中为on.
8.2 shell脚本启动
这第2中自启动脚本,是根据下面情况才使用的
svnserve -d --listen-port 3690 -r /svnroot/repos/svnserve -d --listen-port 3691 -r /svnroot/repo/
svn默认启动端口是3690,这里有两个svn库,所以当出现这样的情况时,上面的服务脚本只会启动一个svn库.所以就需要使用shell脚本来实现启动两个svn库.
vi /root/svn.sh
svn.sh脚本内容:
#!/bin/bashsvnserve -d --listen-port 3690 -r /svnroot/repos/svnserve -d --listen-port 3691 -r /svnroot/repo/
然后添加可执行权限
chmod 700 /root/svn.sh或chmod ug+x /root/svn.sh
添加到自动运行
vi /etc/rc.local
在最后添加一行内容
/root/svn.sh
然后重启服务器,使用ps aux|grep来查看svn是否启动
特点:
一个版本库对应一个配置;
仅能使用svn://协议访问。
参考:
1、CentOS下的SVN服务器搭建过程以及分析
http://www.centoscn.com/CentosServer/ftp/2014/0306/2505.html
2、(总结)CentOS Linux搭建SVN Server配置详解
http://www.ha97.com/4467.html