506629361 发表于 2018-11-21 13:48:27

Centos 6.5 Epel源——apache+SVN

  1.实验环境

  svn server(subversion):192.168.40.129
  svn client(TortoiseSVN):下载地址(http://tortoisesvn.net/downloads.html)
  2.准备epel源
# rpm-ivh http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm
Retrieving http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm
warning: /var/tmp/rpm-tmp.HjLnDh: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing...                ###########################################
   1:epel-release         ########################################### 更新epel源仓库:
# yum repolist  3.安装相关软件包
# yum -y install httpd httpd-devel mod_dav_svn subversion mod_ssl
httpd,mod_dav_svn,httpd-devel,mod_ssl支持WEB形式管理SVN
subversion (SVN服务器)  4.查看是否安装了svn模块
# ls /etc/httpd/modules/ | grep svn
mod_authz_svn.so
mod_dav_svn.so
#查看svn版本:
# svn --version
svn, version 1.6.11 (r934486)
   compiled Mar6 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 access (RA) modules are available:
* ra_neon : Module for accessing a repository via WebDAV protocol using Neon.
- handles 'http' scheme
- handles 'https' scheme
* ra_svn : Module for accessing a repository using the svn network protocol.
- with Cyrus SASL authentication
- handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
- handles 'file' scheme  5.svn服务器的配置:
  新建一个目录用于存储SVN所有文件
# mkdir /data/svn -p  

  新建一个版本仓库
# svnadmin create /data/svn/
# cd /data/svn/
# ls
confdbformathookslocksREADME.txt
#更改/data/svn属主属组:
# chown -R apache.apache /data/svn/  6.配置subversion.conf
  加载mod_dav_svn模块,一般apache2己正常加载这两个模块apache需要加载mod_dav_svn模块。如果apache是按照与预设目录安装的,mod_dav_svn模块应该会安装在apache安装位置(默认路径是/etc/httpd/)的 modules子目录内。同时apache的配置文件httpd.conf(默认路径为etc/httpd/conf/)中已经使用LoadModule指令加载了该模块(如果没有,手动添加)注意这个指令必须出现在其它的Subversion相关指令之前。还要加载mod_authz_svn.so模块。
# vim /etc/httpd/conf.d/subversion.conf
LoadModule dav_svn_module   modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so

   DAV svn
#   SVNParentPath /var/www/svn
    SVNPath /data/svn
    SVNListParentPath on
#   # Limit write permission to list of valid users.
#   
#      # Require SSL connection for password protection.
#      # SSLRequireSSL
#
      AuthType Basic
      AuthName "svn for project"
      AuthUserFile /data/svn/passwdfile
      AuthzSVNAccessFile /data/svn/accessfile
      Require valid-user
#   
  7.添加用户和密码:
# htpasswd -c /data/svn/passwdfile kaibin
New password:
Re-type new password:
Adding password for user kaibin
# htpasswd /data/svn/passwdfile zhangsan
New password:
Re-type new password:
Adding password for user zhangsan  8.重启apache
# /etc/init.d/httpd restart
Stopping httpd:                                          
Starting httpd:  9、下面创建权限访问控制文件,可自行查看具体权限:
# vim /data/svn/accessfile
[/]
*=rw

dev=kaibin
test=zhangsan

@test=r
@dev=r

@test=rw
*=  10.启动svn服务器
# svnserve -d -r /data/svn  11.用客户端登陆:

  12.svn常用命令
  svn服务器地址:192.168.40.129
  1.查看文件详情信息
# svn info http://192.168.40.129/svn-test
Path: svn-test
URL: http://192.168.40.129/svn-test
Repository Root: http://192.168.40.120/svn-test
Repository UUID: ad541a1c-e001-4760-8689-1949c7d67214
Revision: 1
Node Kind: directory
Last Changed Author: kaibin
Last Changed Rev: 1
Last Changed Date: 2015-01-28 18:51:12 -0800 (Wed, 28 Jan 2015)  2.将文件checkout到本地/test
# mkdir /test
# svn checkout http://192.168.40.129/svn-test /test/
A    /test/新建文本文档.txt
Checked out revision 1.
# cd /test/
# ls
新建文本文档.txt  

  3.将新建的文件提交到代码服务器上
# echo "This is a test" >> test.txt
# ls
test.txt新建文本文档.txt
# svn add test.txt
A         test.txt  4.将修改的文件提交到版本库
# svn commit -m "This is a renew" test2.txt
Adding         test2.txt
Transmitting file data .
Committed revision 2.  5.更新到某个版本

[*]  将hosts文件更新到版本4
# svn update -r 4 hosts
U    hosts
Updated to revision 4.

[*]  将所有文件更新到版本4
# svn update
At revision 4.
# svn -r 4 update
At revision 4.  6.显示文件和子目录状态
# svn status -v svn-test/
               4      4 kaibin       svn-test
               4      4 kaibin       svn-test/hosts
               4      1 kaibin       svn-test/新建文本文档.txt
# cd svn-test/
# svn status -v hosts
               4      4 kaibin       hosts  第一列保持相同,第二列显示工作版本号,第三列显示最后一次修改人和版本号.
  7.查看日志
# svn log svn-test/hosts
------------------------------------------------------------------------
r4 | kaibin | 2015-03-05 18:13:46 -0800 (Thu, 05 Mar 2015) | 1 line
xiu gai hosts wen jian..
------------------------------------------------------------------------
r3 | kaibin | 2015-03-05 17:20:38 -0800 (Thu, 05 Mar 2015) | 1 line
This is a test2.
------------------------------------------------------------------------
r2 | kaibin | 2015-03-05 17:19:58 -0800 (Thu, 05 Mar 2015) | 1 line
This is a test.
------------------------------------------------------------------------  8.比较版本之间的差异
# svn diff -r 4:5 svn-test/hosts
Index: svn-test/hosts
===================================================================
--- svn-test/hosts    (revision 4)
+++ svn-test/hosts    (revision 5)
@@ -17,3 +17,4 @@
192.168.40.145    test.server03 test.server03.com
192.168.40.145    test.server03 test.server03.com
192.168.40.145    test.server03 test.server03.com
+192.168.40.148    test.server03 test.server03.com
# svn diff -r 2:5 svn-test/hosts
Index: svn-test/hosts
===================================================================
--- svn-test/hosts    (revision 2)
+++ svn-test/hosts    (revision 5)
@@ -6,3 +6,15 @@
192.168.40.145    test.server03 test.server03.com
192.168.40.145    test.server03 test.server03.com
192.168.40.145    test.server03 test.server03.com
+192.168.40.145    test.server03 test.server03.com
+192.168.40.145    test.server03 test.server03.com
+192.168.40.145    test.server03 test.server03.com
+192.168.40.145    test.server03 test.server03.com
+192.168.40.145    test.server03 test.server03.com
+192.168.40.145    test.server03 test.server03.com
+192.168.40.145    test.server03 test.server03.com
+192.168.40.145    test.server03 test.server03.com
+192.168.40.145    test.server03 test.server03.com
+192.168.40.145    test.server03 test.server03.com
+192.168.40.145    test.server03 test.server03.com
+192.168.40.148    test.server03 test.server03.com  9.查看版本库下的文件和列表
# svn list http://192.168.40.129/svn-test
hosts
新建文本文档.txt  




页: [1]
查看完整版本: Centos 6.5 Epel源——apache+SVN