CentOS6.8 搭建SVN並用鉤子自動實現同步到web目錄
安裝subversion : yum install -y subversion
檢查安裝是否成功: svn --version
創建倉庫目錄: mkdir -p /home/svn/test
創建項目:svnadmin create /home/svn/test
檢查創建是否成功:
(1)cd /home/svn/test
(2) ll #查看生成文件
6.cd /home/svn/test/conf #進入目錄有文件 authz ,passwd, svnserve.conf
7.vim authz #設置用戶權限 在後面添加
[/]
admin = rw
8.vim passwd #設置用戶密碼
[user]
admin = 123456
9.vim svnserve.conf #設置去掉註釋
anon-access = read
auth-access = write
password-db = passwd
authz-db = authz
realm = /home/svn/test #寫自己的創庫
10.啟動svn 服務:svnserve -d -r /home/svn *註*: 不是 svnserve -d -r /home/svn/test
11.在本地安裝TortoiseSVN 測試地址:svn://ip地址/test 輸入用戶密碼
12.實現自動同步
#例如:你的web 目錄是 /www/web
(1)cd /home/svn/test/hooks
(2)cp post-commit.tmpl post-commit
(3)vim post-commit #設置
export LANG=zh_CN.UTF-8
svn co svn://47.92.168.214/test /www/web
LOG_PATH=/tmp/svn_test.log
WEB=/www/web
REPOS="$1"
REV="$2"
svn update --username admin --password 123456 $WEB --no-auth-cache >> $LOG_PATH
保存退出
13.killall svnserve
14.svnserve -d -r /home/svn #重啟服務
CentOS6.8 搭建SVN並用鉤子自動實現同步到web目錄