linux install SVN (CentOS_6.6)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux install SVN (CentOS_6.6)相关的知识,希望对你有一定的参考价值。

一、环境准备

system:CentOS_6.6

IP:192.168.30.129

安装yum:

rpm -Uhv http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

二、安装SVN

[email protected]/0 # yum -y install subversion
Loaded plugins: fastestmirror, security
Setting up Install Process
Determining fastest mirrors
epel/metalink                                                                                                     | 5.0 kB     00:00     
 * base: mirrors.btte.net
 * epel: mirrors.opencas.cn
 * extras: mirrors.btte.net
 * updates: mirrors.btte.net
base                                                                                                              | 3.7 kB     00:00     
base/primary_db                                                                                                   | 4.6 MB     00:06     
epel                                                                                                              | 4.3 kB     00:00     
epel/primary_db                                                                                                   | 5.7 MB     00:44     
extras                                                                                                            | 2.9 kB     00:00     
extras/primary_db                                                                                                 |  33 kB     00:00     
updates                                                                                                           | 3.4 kB     00:00     
updates/primary_db                                                                                                | 3.3 MB     00:04     
Resolving Dependencies
--> Running transaction check
---> Package subversion.x86_64 0:1.6.11-15.el6_7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=========================================================================================================================================
 Package                          Arch                         Version                               Repository                     Size
=========================================================================================================================================
Installing:
 subversion                       x86_64                       1.6.11-15.el6_7                       updates                       2.3 M

Transaction Summary
=========================================================================================================================================
Install       1 Package(s)

Total download size: 2.3 M
Installed size: 12 M
Downloading Packages:
subversion-1.6.11-15.el6_7.x86_64.rpm                                                                             | 2.3 MB     00:02     
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
 Userid : CentOS-6 Key (CentOS 6 Official Signing Key) <[email protected]>
 Package: centos-release-6-6.el6.centos.12.2.x86_64 (@anaconda-CentOS-201410241409.x86_64/6.6)
 From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing : subversion-1.6.11-15.el6_7.x86_64                                                                                     1/1 
  Verifying  : subversion-1.6.11-15.el6_7.x86_64                                                                                     1/1 

Installed:
  subversion.x86_64 0:1.6.11-15.el6_7                                                                                                    

Complete!

输入rpm -ql subversion查看安装位置

[email protected]/0 # rpm -ql subversion
/etc/bash_completion.d
/etc/bash_completion.d/subversion
/etc/rc.d/init.d/svnserve
/etc/subversion
/usr/bin/svn
/usr/bin/svnadmin
/usr/bin/svndumpfilter
/usr/bin/svnlook
/usr/bin/svnserve
/usr/bin/svnsync
/usr/bin/svnversion
....

查看svn 帮助

[email protected]/0 # svn --help
usage: svn <subcommand> [options] [args]
Subversion command-line client, version 1.6.11.
Type ‘svn help <subcommand>‘ for help on a specific subcommand.
Type ‘svn --version‘ to see the program version and RA modules
  or ‘svn --version --quiet‘ to see just the version number.

Most subcommands take file and/or directory arguments, recursing
on the directories.  If no arguments are supplied to such a
command, it recurses on the current directory (inclusive) by default.

Available subcommands:
   add
   blame (praise, annotate, ann)
   cat
   changelist (cl)
   checkout (co)
   cleanup
   commit (ci)
   copy (cp)
   delete (del, remove, rm)
   diff (di)
   export
   help (?, h)
   import
   info
   list (ls)
   lock
   log
   merge
   mergeinfo
   mkdir
   move (mv, rename, ren)
   propdel (pdel, pd)
   propedit (pedit, pe)
   propget (pget, pg)
   proplist (plist, pl)
   propset (pset, ps)
   resolve
   resolved
   revert
   status (stat, st)
   switch (sw)
   unlock
   update (up)

Subversion is a tool for version control.
For additional information, see http://subversion.tigris.org/

[email protected]/0 # svnadmin --help
general usage: svnadmin SUBCOMMAND REPOS_PATH  [ARGS & OPTIONS ...]
Type ‘svnadmin help <subcommand>‘ for help on a specific subcommand.
Type ‘svnadmin --version‘ to see the program version and FS modules.

Available subcommands:
   crashtest
   create
   deltify
   dump
   help (?, h)
   hotcopy
   list-dblogs
   list-unused-dblogs
   load
   lslocks
   lstxns
   pack
   recover
   rmlocks
   rmtxns
   setlog
   setrevprop
   setuuid
   upgrade
   verify

三、创建svn版本库目录

[email protected]/0 # mkdir -p /usr/local/svn/test

四、创建版本库

[email protected]/0 # svnadmin create /usr/local/svn/test
Test_1 [~] 2016-01-10 15:03:28
[email protected]/0 # ll /usr/local/svn/test
total 24
drwxr-xr-x. 2 root root 4096 Jan 10 15:03 conf
drwxr-sr-x. 6 root root 4096 Jan 10 15:03 db
-r--r--r--. 1 root root    2 Jan 10 15:03 format
drwxr-xr-x. 2 root root 4096 Jan 10 15:03 hooks
drwxr-xr-x. 2 root root 4096 Jan 10 15:03 locks
-rw-r--r--. 1 root root  229 Jan 10 15:03 README.txt

五、进入conf目录(该svn版本库配置文件)

[email protected]/0 # cd conf/
Test_1 [/usr/local/svn/test/conf] 2016-01-10 15:12:38
[email protected]/0 # ll
total 12
-rw-r--r--. 1 root root 1080 Jan 10 15:03 authz
-rw-r--r--. 1 root root  309 Jan 10 15:03 passwd
-rw-r--r--. 1 root root 2279 Jan 10 15:03 svnserve.conf

authz文件是权限控制文件

passwd是帐号密码文件

svnserve.conf SVN服务配置文件

六、设置帐号密码

[email protected]/0 # vim 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 = test123
other = test123

在[users]块中添加用户和密码,格式:帐号=密码,如test = test123

七、设置权限

[email protected]/0 # vim authz
....
[/]
test = rw
other = r

意思是版本库的根目录test对其有读写权限,other只有读权限。

八、修改svnserve.conf文件

[email protected]/0 # vim svnserve.conf
....
anon-access = none
auth-access = write
password-db = passwd
authz-db = authz
realm = /usr/local/svn/test

打开下面的几个注释:

anon-access = none #匿名用户不可访问

auth-access = write #授权用户可写

password-db = passwd #使用哪个文件作为账号文件

authz-db = authz #使用哪个文件作为权限文件

realm = /var/svn/svnrepos # 认证空间名,版本库所在目录

九、启动svn版本库

[email protected]/0 # svnserve -d -r /usr/local/svn
[email protected]/0 # ps -ef |grep svn
root      3082     1  0 15:31 ?        00:00:00 svnserve -d -r /usr/local/svn

十、测试连接

[email protected]/0 # mkdir -p /opt/test
Test_1 [/opt] 2016-01-10 15:37:01
[email protected]/0 # cd /opt/test/
Test_1 [/opt/test] 2016-01-10 15:37:08
[email protected]/0 # svn co svn://127.0.0.1/test /opt/test/
Authentication realm: <svn://127.0.0.1:3690> /usr/local/svn/test
Password for ‘root‘: 
Authentication realm: <svn://127.0.0.1:3690> /usr/local/svn/test
Username: test
Password for ‘test‘: 

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

   <svn://127.0.0.1:3690> /usr/local/svn/test

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
Checked out revision 0.

[email protected]/0 # svn info
Path: .
URL: svn://127.0.0.1/test
Repository Root: svn://127.0.0.1/test
Repository UUID: ec5619f6-c7b2-4018-a560-616f7d6462cc
Revision: 0
Node Kind: directory
Schedule: normal
Last Changed Rev: 0
Last Changed Date: 2016-01-10 15:45:56 +0000 (Sun, 10 Jan 2016)

linux svn 更多命令可以查询帮助信息!

十一、测试上传文件,查看版本

[email protected]/0 # touch file
Test_1 [/opt/test] 2016-01-10 16:15:57
[email protected]/0 # echo "svn is test" > file 
Test_1 [/opt/test] 2016-01-10 16:16:14
[email protected]/0 # svn add file 
A         file
Test_1 [/opt/test] 2016-01-10 16:16:21
[email protected]/0 # svn commit file -m ‘test‘
Adding         file
Transmitting file data .
Committed revision 1.
Test_1 [/opt/test] 2016-01-10 16:16:56
[email protected]/0 # ll
total 4
-rw-r--r--. 1 root root 12 Jan 10 16:16 file
Test_1 [/opt/test] 2016-01-10 16:17:08
[email protected]/0 # svn info file 
Path: file
Name: file
URL: svn://127.0.0.1/test/file
Repository Root: svn://127.0.0.1/test
Repository UUID: ec5619f6-c7b2-4018-a560-616f7d6462cc
Revision: 1
Node Kind: file
Schedule: normal
Last Changed Author: test
Last Changed Rev: 1
Last Changed Date: 2016-01-10 16:16:42 +0000 (Sun, 10 Jan 2016)
Text Last Updated: 2016-01-10 16:16:14 +0000 (Sun, 10 Jan 2016)
Checksum: 304b5e95556c9066f5aa1268ede6df6a

显示版本已更新为 1

十二、在Windows上测试

首先安装TortoiseSVN

找地方新建svn目录,右击 - 检出

技术分享图片

添加svn版本库URL 与 检出 目录

技术分享图片

输入账户密码 user: test passwd: test123

技术分享图片

可以看到刚才服务器提交的file文件已经更新

技术分享图片

Windows更多操作这里不多说,看帮助吧!

以上是关于linux install SVN (CentOS_6.6)的主要内容,如果未能解决你的问题,请参考以下文章

Centos 安装svn详细步骤

Centos 下搭建SVN + Apache 服务器

Centos Svn 仓库部署

Linux install svn server

Centos 安装SVN

Centos7安装SVN