linux 搭建SVN服务器

subversion(简称svn)是近几年崛起的版本管理软件,是cvs的接班人,目前绝大多数开源软件都使用svn作为代码版本管理软件。Subversion支持linuxwindows,但较多安装在linux下。
svn的基本工作原理: 在一台服务器上建立一个源代码库,库里可以存放许多不同项目的源程序。有源代码库管理员统一管理这些源程序。每个用户在使用源代码库之前,首先要把源代码库里德项目文件下载到本地,然后开发人员可以在本地修改,左后用svn命令进行提交,游源代码库统一管理修改。

1、通过本地yum安装svn服务,使用的安装包subversion
点击( 此处 )折叠或打开
  1. yum install -y subversion httpd mod_dav_svn
2、创建版本库
点击( 此处 )折叠或打开
  1. svnadmin create /myrepos
3、配置svnserve , 在上述目录 /myrepos/conf 生成3个主要的配置文件
点击( 此处 )折叠或打开
  1. [root@mhxy162 conf]# ll
  2. total 12
  3. -rw-r--r-- 1 root root 1080 Jul 13 05:46 authz
  4. -rw-r--r-- 1 root root 309 Jul 13 05:46 passwd
  5. -rw-r--r-- 1 root root 2279 Jul 13 05:46 svnserve.conf
3.1 修改svnserve.conf

点击(此处)折叠或打开

  1. anon-access = read             #匿名用户可以读
  2. auth-access = write            #认证用户可以写
  3. password-db = passwd           #密码库文件,默认使用的是同一目录下的passwd文件作为用户密码库
  4. authz-db = authz               #认证权限文件
  5. realm = My First Repository for Bob Le    #登录提示信息
3.2 修改passwd,设置登录的账号和密码  # 为示例
点击( 此处 )折叠或打开
  1. [users]
  2. # harry = harryssecret
  3. # sally = sallyssecret
  4. libo = 123456
  5. fanfan =123456
3.3 修改authz权限 文件 ,设置所有权限 都为可读可写

点击(此处)折叠或打开

  1. [groups]                #默认存在
  2. check = libo,fanfan     #定义组,多个user用逗号分开;user必须是passwd文件中存在的
  3. [/]                     #表示当前版本库  及/myrepos
  4. @check = rw             # @check 表示这个组的权限
  5. * =                     #除了上面定义的权限的用户外,其他的成员都没有权限

     svn 目录格式:

          [/]
          @用户组名称 = 权限 (rw)
          用户名称 =  权限 (rw)
          * = 

4、 启动svnserve 服务

点击(此处)折叠或打开

  1. svnserve -d -r /myrepos/ 
5、测试服务

点击(此处)折叠或打开

  1. [root@mhxy162 ~]# svn import /root/localsvn/ file:///myrepos/ -m "first edit"
  2. Adding /root/localsvn/1.html
  3. Adding /root/localsvn/2.html
  4. Committed revision 1.
  5. [root@mhxy162 ~]#
6、 客户端测试svn
6.1 文件导入

点击(此处)折叠或打开

  1. [root@localhost ~]# mkdir editwebsite
  2. [root@localhost ~]# cd editwebsite/
  3. [root@localhost editwebsite]# ll
  4. total 0
  5. [root@localhost editwebsite]# touch 3.html 4.html ; cd
  6. [root@localhost ~]# svn import /root/editwebsite/ svn://192.168.137.162/myrepos -m "from 163 edit"
  7. Authentication realm: <svn://192.168.137.162:3690> My First Repository for Bob Le
  8. Password for 'root':
  9. Authentication realm: <svn://192.168.137.162:3690> My First Repository for Bob Le
  10. Username: libo
  11. Password for 'libo':
  12. -----------------------------------------------------------------------
  13. ATTENTION! Your password for authentication realm:
  14. <svn://192.168.137.162:3690> My First Repository for Bob Le
  15. can only be stored to disk unencrypted! You are advised to configure
  16. your system so that Subversion can store passwords encrypted, if
  17. possible. See the documentation for details.
  18. You can avoid future appearances of this warning by setting the value
  19. of the 'store-plaintext-passwords' option to either 'yes' or 'no' in
  20. '/root/.subversion/servers'.
  21. -----------------------------------------------------------------------
  22. Store password unencrypted (yes/no)? no
  23. Adding editwebsite/3.html
  24. Adding editwebsite/4.html
  25. Committed revision 2.
  26. [root@localhost ~]#
6.2 文件取出

点击(此处)折叠或打开

  1. [root@localhost ~]# svn checkout svn://192.168.137.162/myrepos/ downsource
  2. Authentication realm: <svn://192.168.137.162:3690> My First Repository for Bob Le
  3. Password for 'libo':
  4. -----------------------------------------------------------------------
  5. ATTENTION! Your password for authentication realm:
  6. <svn://192.168.137.162:3690> My First Repository for Bob Le
  7. can only be stored to disk unencrypted! You are advised to configure
  8. your system so that Subversion can store passwords encrypted, if
  9. possible. See the documentation for details.
  10. You can avoid future appearances of this warning by setting the value
  11. of the 'store-plaintext-passwords' option to either 'yes' or 'no' in
  12. '/root/.subversion/servers'.
  13. -----------------------------------------------------------------------
  14. Store password unencrypted (yes/no)? no
  15. A downsource/3.html
  16. A downsource/4.html
  17. Checked out revision 2.

  18. [root@localhost ~]# ll downsource/
  19. total 0
  20. -rw-r--r-- 1 root root 0 Jul 12 22:51 3.html
  21. -rw-r--r-- 1 root root 0 Jul 12 22:51 4.html
  22. [root@localhost ~]#
6.3 代码添加
点击( 此处 )折叠或打开
  1. [root@localhost ~]# cd downsource/
  2. [root@localhost downsource]# ll
  3. total 0
  4. -rw-r--r-- 1 root root 0 Jul 12 22:51 3.html
  5. -rw-r--r-- 1 root root 0 Jul 12 22:51 4.html
  6. [root@localhost downsource]# touch libo.html
  7. [root@localhost downsource]# svn add libo.html
  8. A libo.html
  9. [root@localhost downsource]# svn commit -m "third edit"
  10. Authentication realm: <svn://192.168.137.162:3690> My First Repository for Bob Le
  11. Password for 'libo':
  12. -----------------------------------------------------------------------
  13. ATTENTION! Your password for authentication realm:
  14. <svn://192.168.137.162:3690> My First Repository for Bob Le
  15. can only be stored to disk unencrypted! You are advised to configure
  16. your system so that Subversion can store passwords encrypted, if
  17. possible. See the documentation for details.
  18. You can avoid future appearances of this warning by setting the value
  19. of the 'store-plaintext-passwords' option to either 'yes' or 'no' in
  20. '/root/.subversion/servers'.
  21. -----------------------------------------------------------------------
  22. Store password unencrypted (yes/no)? no
  23. Adding libo.html
  24. Transmitting file data .
  25. Committed revision 3.
  26. [root@localhost downsource]#

参考博客:
http://www.ha97.com/4467.html

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/27039319/viewspace-2121928/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/27039319/viewspace-2121928/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值