Centos6 SVN

注: 阿里云服务器需要在后台添加端口

1.安装svn

[plain]  view plain  copy
  1. yum install subversion  
2.查看是否安装成功

[plain]  view plain  copy
  1. svnserve --version  

安装成功回显如下信息

svnserve, version 1.6.6 (r40053)
   compiled Dec 25 2012, 13:14:38
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_fs : Module for working with a plain file (FSFS) repository.
Cyrus SASL authentication is available.

3.创建仓库地址

[plain]  view plain  copy
  1. mkdir /var/web  
4.创建SVN项目

[plain]  view plain  copy
  1. svnadmin create /var/web  
5.查看是否创建成功

[plain]  view plain  copy
  1. cd /var/web  
如果创建成功,目录下面会多出conf,db,format,hooks,locks, README.txt等文件,说明一个SVN库建立完成。

6.配置代码库

进入上面生成的文件夹conf下,进行配置

[plain]  view plain  copy
  1. cd /var/web/conf  
7.用户密码passwd配置

[plain]  view plain  copy
  1. vim passwd  
[plain]  view plain  copy
  1. [users]  
  2. # harry = harryssecret  
  3. # sally = sallyssecret  
  4. # 用户名 = 密码  
  5. test = 123456789   
8.权限控制authz配置

[plain]  view plain  copy
  1. vim authz  
[plain]  view plain  copy
  1. #在最底部写入如下代码  
  2. #设置[/]代表根目录下所有的资源  
  3. #test为SVN用户名  
  4. #rw为读写权限  
  5. [/]  
  6. test = rw     
9.服务svnserve.conf配置

[plain]  view plain  copy
  1. vim svnserve.conf  
[plain]  view plain  copy
  1. <span style="color:#ff0000;">这里特别注意,下面的代码头部必须顶格,不要有空格</span>  
[plain]  view plain  copy
  1. [general]  
  2. #匿名访问的权限,可以是read,write,none,默认为read  
  3. anon-access=none  
  4. #使授权用户有写权限   
  5. auth-access=write  
  6. #密码数据库的路径   
  7. password-db=passwd  
  8. #访问控制文件   
  9. authz-db=authz  
  10. #认证命名空间,subversion会在认证提示里显示,并且作为凭证缓存的关键字   
  11. realm=/var/web  
10.防火墙开发3690端口

[plain]  view plain  copy
  1. vim /etc/sysconfig/iptables  
[plain]  view plain  copy
  1. -A INPUT -m state --state NEW -m tcp -p tcp --dport 3690 -j ACCEPT  
[plain]  view plain  copy
  1. #重启防火墙  
  2. service iptables restart  
11.停止/启动SVN

[plain]  view plain  copy
  1. # 停止  
  2. killall svnserve  
  3. # 启动  
  4. svnserve -d -r /var/web  
13.设置开机启动

[plain]  view plain  copy
  1. # 编辑脚本文件  
  2. vim /etc/rc.d/rc.local  
[plain]  view plain  copy
  1. 这里的svnserve路径写绝对路径  
  2. 查询绝对路径  
  3. which svnserve  
[plain]  view plain  copy
  1. # 写入如下代码  
  2.   
  3. #!/bin/sh  
  4. #  
  5. # This script will be executed *after* all the other init scripts.  
  6. # You can put your own initialization stuff in here if you don't  
  7. # want to do the full Sys V style init stuff.  
  8.   
  9. touch /var/lock/subsys/local  
  10. /usr/bin/svnserve -d -r /var/web  

14.到此SVN安装完成

15.设置post-commit

我们先将SVN版本库中的一个项目checkout到网站目录, 这时,网站目录已成为SVN的工作副本,接下来利用SVN的钩子让这个工作副本自动更新。

[plain]  view plain  copy
  1. #               仓库地址   站点地址  
  2. svn co file:///var/web/ /home/www/  
  3. #  打开  
  4. cd /var/web/hooks  
  5. # 复制一份  
  6. cp post-commit.tmpl post-commit  
16.在post-commit中,添加如下信息:

[plain]  view plain  copy
  1. REPOS="$1"  
  2. REV="$2"  
  3. export LANG=zh_CN.UTF8  
  4. svn update --username SVN账号 --password SVN密码 /home/www  
17.最后个给权限

[plain]  view plain  copy
  1. chmod 777 post-commit  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值