標籤:style blog ar io color os sp strong on
開幹!詳細的碼!
第一步,不多說了:安裝
yum install subversion
第二步:建立倉庫目錄
mkdir /home/svn
第三步:建立版本庫
svnadmin create /home/svn/banbenku運行svnsvnsever -d -r /home/svn/banbenku
第四步:修改版本庫的配置
進入 /home/svn/banbenku/conf 目錄下修改,如下:
[general]anon-access = noneauth-access = writepassword-db = /home/svn/passwd ##使用者的名字和密碼檔案realm = newguangwang ##版本庫名
第五部:設定使用者名稱以及密碼
進入 /home/svn
vim passwd 建立和編輯passwd檔案,格式以下
[users]xiaonan= 1213456xub = 1234156lao = 1234156
第六步:建立鉤子,post-commit檔案
進入/home/svn/banbenku/hooks
vim post-commit 建立和編輯鉤子檔案,內容如下::
#!/bin/shexport LANG=zh_CN.utf8#Set variableREPOS="$1"REV="$2" SVN=/usr/bin/svn ##可通過whereis svn得出WEB=/home/wwwroot/newguangwang ##想要放網站目錄的地方,此處的目錄必須和版本庫名字相同,沒有請建立LOG=/home/auto_svn.log ##日記檔案 #update the code from the SVN$SVN update $WEB --username xiaonange --password 123456 2>/home/svn/newguangwang/test.log if [ $? == 0 ];then echo "$REPOS" "$REV" >>/home/svn/newguangwang/test.log echo `date` echo "##############################"fi
第七步:給予post-commit運行許可權
chmod +x post-commit;
此步切記!
第七步:檢出版本庫到網站目錄
svn checkout file:///home/svn/banbenku /home/wwwroot/newguangwang
給予
Ok!跑起來吧
svn的安裝以及post-commit即時更新網站