注: 阿里云服务器需要在后台添加端口
1.安装svn
- yum install subversion
- 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.创建仓库地址
- mkdir /var/web
- svnadmin create /var/web
- cd /var/web
6.配置代码库
进入上面生成的文件夹conf下,进行配置
- cd /var/web/conf
- vim passwd
- [users]
- # harry = harryssecret
- # sally = sallyssecret
- # 用户名 = 密码
- test = 123456789
- vim authz
- #在最底部写入如下代码
- #设置[/]代表根目录下所有的资源
- #test为SVN用户名
- #rw为读写权限
- [/]
- test = rw
- vim svnserve.conf
- <span style="color:#ff0000;">这里特别注意,下面的代码头部必须顶格,不要有空格</span>
- [general]
- #匿名访问的权限,可以是read,write,none,默认为read
- anon-access=none
- #使授权用户有写权限
- auth-access=write
- #密码数据库的路径
- password-db=passwd
- #访问控制文件
- authz-db=authz
- #认证命名空间,subversion会在认证提示里显示,并且作为凭证缓存的关键字
- realm=/var/web
- vim /etc/sysconfig/iptables
- -A INPUT -m state --state NEW -m tcp -p tcp --dport 3690 -j ACCEPT
- #重启防火墙
- service iptables restart
- # 停止
- killall svnserve
- # 启动
- svnserve -d -r /var/web
- # 编辑脚本文件
- vim /etc/rc.d/rc.local
- 这里的svnserve路径写绝对路径
- 查询绝对路径
- which svnserve
- # 写入如下代码
- #!/bin/sh
- #
- # This script will be executed *after* all the other init scripts.
- # You can put your own initialization stuff in here if you don't
- # want to do the full Sys V style init stuff.
- touch /var/lock/subsys/local
- /usr/bin/svnserve -d -r /var/web
14.到此SVN安装完成
15.设置post-commit
我们先将SVN版本库中的一个项目checkout到网站目录, 这时,网站目录已成为SVN的工作副本,接下来利用SVN的钩子让这个工作副本自动更新。- # 仓库地址 站点地址
- svn co file:///var/web/ /home/www/
- # 打开
- cd /var/web/hooks
- # 复制一份
- cp post-commit.tmpl post-commit
- REPOS="$1"
- REV="$2"
- export LANG=zh_CN.UTF8
- svn update --username SVN账号 --password SVN密码 /home/www
- chmod 777 post-commit