链接
https://www.linuxidc.com/Linux/2017-05/143668.htm
CentOS6.8 搭建SVN并用钩子自动实现同步到Web目录
vim编辑每行前面不能有空格
一 安装
yum install subversion
二 检查是否安装成功
svn --version
三 创建仓库目录
mkdir –p /home/svnroot/test
另一个做法:
mkdir /home/svndata
svnserve -d -r /home/svndata
svnadmin create /home/svndata/midtalk
四 创建项目
注意:前面不要有空格,否则不识别,会报错
svnadmin create /home/svnroot/test
五 检查是否创建成功
cd /home/svnroot/test
ls // 查看创建成功后生成的文件
六 进入conf目录配置该版本库的文件
authz 是权限控制文件
passwd 是帐号密码文件
svnserve.conf 是SVN服务配置文件
6.1 配置passwd,语法:用户名=密码
[users]
test1 = 123456
test2 = 123456
6.2 配置authz用户权限文件
[/]
*=rw
[/]
test1 = rw
test2 = r
6.3 配置svnserve.conf文件,取消以下几个注释即可
anon-access = read #匿名用户可读
auth-access = write #授权用户可写
password-db = passwd #使用哪个文件作为账号文件
authz-db = authz #使用哪个文件作为权限文件
realm = /home/svnroot/test #认证空间名,版本库所在目录
#realm 可以不写
七 启动 SVN服务
svnserve -d -r /home/svnroot
注意:不是svnserve -d -r /home/svnroot/test
八 在本机安装TortoiseSVN
输入svn://你的ip地址/test
如果弹出输入账号密码的对话框,表示上述设置正确。
九 实现自动同步
假设web目录是 /home/www/test
在/home/svnroot/test/hooks下创建post-commit文件,文件设置可执行权限
cp post-commit.tmpl post-commit
chmod 755 post-commit
打开post-commit文件,加入以下内容 //注释:是post-commit而不是commit.teml
export LANG=zh_CN.UTF-8
svn co svn://你的ip地址/test /home/www/test
LOG_PATH=/tmp/svn_test.log
WEB=/home/www/test
REPOS="$1"
REV="$2"
svn update --username test1 --password 123456 $WEB --no-auth-cache >> $LOG_PATH
export LANG=zh_CN.UTF-8
svn co svn://39.108.37.76/swzl /opt/lampp/htdocs/swzl
LOG_PATH=/tmp/svn_test.log
WEB=/opt/lampp/htdocs/midtalk
REPOS="$1"
REV="$2"
svn update --username he --password he $WEB --no-auth-cache >> $LOG_PATH ||exit 1 exit 0
最后,回到shell
svn co svn://你的ip/test /home/www/test
输入账号密码,即可实现自动同步。
Ubuntu 14.04 下搭建SVN服务器 SVN:// http://www.linuxidc.com/Linux/2015-01/111956.htm
CentOS 7下安装iF.svnadmin实现Web方式管理SVN(源码安装) http://www.linuxidc.com/Linux/2016-08/134214.htm
CentOS7.2 编译安装SVN1.9.5客户端 http://www.linuxidc.com/Linux/2017-03/141387.htm
SVN 服务器搭建步骤及使用实战 http://www.linuxidc.com/Linux/2017-01/139282.htm
Windows下SVN服务器搭建和使用 + 客户端重新设置密码 http://www.linuxidc.com/Linux/2013-05/85189p5.htm
CentOS 6.6搭建SVN服务器 http://www.linuxidc.com/Linux/2016-12/137864.htm
CentOS 7.2下Nginx+MySQL+PHP-FPM+SVN配置Walle自动化部署系统详解 http://www.linuxidc.com/Linux/2016-11/137703.htm
CentOS 7.1 下SVN安装与配置 http://www.linuxidc.com/Linux/2016-12/138637.htm
CentOS 6.8 搭建SVN(版本控制系统)及SVN的使用 http://www.linuxidc.com/Linux/2017-04/143093.htm
Subversion (SVN) 的详细介绍:请点这里
Subversion (SVN) 的下载地址:请点这里
本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-05/143668.htm
错误的解决放方法:
Error: post-commit hook failed (
exit
code 127) with output:
Error:
/svn/project/hooks/post-commit
: line 53: mailer.py:
command
not found
[root@v01 hooks]
# vi post-commit
/usr/bin/svn
update --username user01 --password 123
/alidata/www/project
--no-auth-cache>
/alidata/log/svn/svn
.log ||
exit
1
exit
0
#加上 || exit 1> 和 exit 0 (问题解决!!!)