类别:原创 服务器

本文参考
svn安装参考 http://blog.csdn.net/sxhong/article/details/9176881
svn命令参考 http://blog.csdn.net/gexiaobaohelloworld/article/details/7752862

第一:说明,软件说明,和安装的目的
架设基于linux下的SVN服务器,进行版本控制。

第二:本例操作环境
所使用的系统环境为 Centos 6.5 64位操作系统

[root@tian ~]# uname -a
Linux tian.test.com 2.6.32-431.11.2.el6.x86_64 #1 SMP Tue Mar 25 19:59:55 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
[root@tian ~]# hostname
tian.test.com
[root@tian ~]# more /etc/redhat-release
CentOS release 6.5 (Final)
[root@tian ~]#

第三:服务器安装配置
1.  安装必须的软件包

subversion

[root@tian ~]# yum install subversion -y
[root@tian ~]# svnserve --version
svnserve, version 1.6.11 (r934486)
   compiled Mar  6 2014, 10:49:10

Copyright (C) 2000-2009 CollabNet.
Subversion is open source software, see http://subversion.tigris.org/
This product includes software developed by CollabNet (http://www.Collab.Net/).

The following repository back-end (FS) modules are available:

* fs_base : Module for working with a Berkeley DB repository.
* fs_fs : Module for working with a plain file (FSFS) repository.

Cyrus SASL authentication is available.

有了SVN软件后还需要建立SVN库


2.创建svn仓库
[root@tian ~]#
[root@tian ~]# mkdir /svn
[root@tian ~]# svnadmin create /svn
执行上面的命令后,自动建立多个文件, 分别是conf, db, format, hooks, locks, README.txt。
[root@tian ~]# ls /svn
conf  db  format  hooks  locks  README.txt
[root@tian ~]#

3.修改svn用户认证文件
[root@tian ~]# cat /svn/conf/passwd | egrep -v "^#|^$"         
[users]
tian = tian1234

4.修改svn用户权限控制文件
[root@tian ~]# cat /svn/conf/authz | egrep -v "^#|^$"       
[aliases]
[groups]
[/]
tian = wr
[root@tian ~]#

5.修改svn服务器配置文件
[root@tian ~]# cat /svn/conf/svnserve.conf | egrep -v "^#|^$"  
[general]
anon-access = none # 使非授权用户无法访问
auth-access = write # 使授权用户有写权限
password-db = password
authz-db = authz   # 访问控制文件
realm = My First Repository # 描述
[sasl]
以上语句都必须顶格写, 左侧不能留空格, 否则会出错.
[root@tian ~]#

第四:启动svnserve服务
1.编辑服务进程文件/etc/init.d/svnserve 在最前面增加一行


OPTIONS=" -r /svn"

2.启动svnserve服务
[root@tian ~]# service  svnserve restart
Stopping svnserve:                                         [  OK  ]
Starting svnserve:                                         [  OK  ]
[root@tian ~]#
[root@tian ~]# netstat -tlnp | grep svn
tcp        0      0 0.0.0.0:3690                0.0.0.0:*                   LISTEN      3288/svnserve      
[root@tian ~]#

3.设置svn开机自启动
[root@tian samba]# chkconfig svnserve on

当然也可以

好了,通过以上配置,你的svn就可以了。

第五:测试
[root@tian ~]# svn co svn://127.0.0.1 svntest --username tian --password tian1234

-----------------------------------------------------------------------
ATTENTION!  Your password for authentication realm:

   <svn://127.0.0.1:3690> My First Repository

can only be stored to disk unencrypted!  You are advised to configure
your system so that Subversion can store passwords encrypted, if
possible.  See the documentation for details.

You can avoid future appearances of this warning by setting the value
of the 'store-plaintext-passwords' option to either 'yes' or 'no' in
'/root/.subversion/servers'.
-----------------------------------------------------------------------
Store password unencrypted (yes/no)? yes
A    svntest/Desktop.ini
Checked out revision 1.
[root@tian ~]#
[root@tian ~]# touch svntest/test
[root@tian ~]# svn update svntest/
At revision 1.
[root@tian ~]#
[root@tian ~]# svn add svntest/test
A         svntest/test
[root@tian ~]# svn ci -m "test" svntest/test
Adding         svntest/test
Transmitting file data .
Committed revision 2.
[root@tian ~]#

第六:补充

1.也可以不使用服务方式启svn 如下
[root@tian ~]# svnserve -d -r /svn
[root@tian ~]#


2.如果已经有svn在运行,可以换一个端口运行
[root@tian ~]# svnserve -d -r /svn --listen-port 3391
这样同一台服务器可以运行多个svnserver

好了,启动成功后,就可以使用了。

至此 所有配置完成