創建一個新的版本庫: 再建一個工作副本: 配許可權: 進入該目錄後,checkout出一個副本,用於同步上線上伺服器的路徑: 配WEB: 我這裡是開一個nginx vhost http://darkyin.blog.51cto.com/6260426/1361132 ...
創建一個新的版本庫:
[root@centos03 svn]# pwd /home/svn [root@centos03 svn]# svnadmin create webtest [root@centos03 svn]# tree webtest/ webtest/ ├── conf │ ├── authz │ ├── passwd │ └── svnserve.conf ├── db │ ├── current │ ├── format │ ├── fsfs.conf │ ├── fs-type │ ├── min-unpacked-rev │ ├── rep-cache.db │ ├── revprops │ │ └── 0 │ │ └── 0 │ ├── revs │ │ └── 0 │ │ └── 0 │ ├── transactions │ ├── txn-current │ ├── txn-current-lock │ ├── txn-protorevs │ ├── uuid │ └── write-lock ├── format ├── hooks │ ├── post-commit.tmpl │ ├── post-lock.tmpl │ ├── post-revprop-change.tmpl │ ├── post-unlock.tmpl │ ├── pre-commit.tmpl │ ├── pre-lock.tmpl │ ├── pre-revprop-change.tmpl │ ├── pre-unlock.tmpl │ └── start-commit.tmpl ├── locks │ ├── db.lock │ └── db-logs.lock └── README.txt 10 directories, 28 files
再建一個工作副本:
[root@centos03 www]# pwd /alidata/www [root@centos03 www]# mkdir webtest [root@centos03 www]# #授權:否則提交會報許可權錯誤! [root@centos03 www]# chmod -R 777 webtest/
配許可權:
[root@centos03 conf]# vi svnserve.conf
[general] ### These options control access to the repository for unauthenticated ### and authenticated users. Valid values are "write", "read", ### and "none". The sample settings below are the defaults. anon-access = read auth-access = write password-db = /home/svn/webtest/conf/passwd authz-db = /home/svn/webtest/conf/authz
[root@centos03 conf]# vi passwd
[users]
# harry = harryssecret
# sally = sallyssecret
svnadmin = 123456
test = 123456
[root@centos03 webtest]# vi /home/svn/webtest/conf/authz
[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe
admin = svnadmin
user = test
[/]
@admin = rw
[/webtest]
@admin = rw
* =
# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
[root@centos03 webtest]# ps -ef |grep svn
root 2586 1 0 13:33 ? 00:00:00 svnserve -d -r /home/svn/webtest/
root 2590 2475 0 13:33 pts/0 00:00:00 grep svn
進入該目錄後,checkout出一個副本,用於同步上線上伺服器的路徑:
[root@centos03 www]# svn co svn://192.168.1.72/webtest svn: URL 'svn://192.168.1.72/webtest' doesn't exist
[root@centos03 www]# ls /home/svn/ test webtest #有兩個版本庫啟動的時候應該是:svnserve -d -r /home/svn/
[root@centos03 www]# ps -ef|grep svn root 2650 1 0 14:00 ? 00:00:00 svnserve -d -r /home/svn/ root 2678 2475 0 14:04 pts/0 00:00:00 grep svn
[root@centos03 www]# svn co svn://192.168.1.72/webtest Checked out revision 0. [root@centos03 www]# ls phpwind sx webtest xxzz
配WEB:
我這裡是開一個nginx vhost
[root@centos03 vhosts]# vi webtest.conf
server {
listen 83;
server_name localhost;
index index.html index.htm index.php;
root /alidata/www/webtest;
location ~ .*\.(php|php5)?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
include /alidata/server/nginx/conf/rewrite/default.conf;
access_log /alidata/log/nginx/access/webtest.log;
}
[root@centos03 vhosts]# service nginx reload Reloading nginx!
[root@centos03 hooks]# cp post-commit.tmpl post-commit
[root@centos03 hooks]# which svn
/usr/bin/svn
[root@centos03 hooks]# vi post-commit [root@centos03 hooks]# pwd /home/svn/webtest/hooks REPOS="$1" REV="$2" SVN=/usr/bin/svn WEB=/alidata/www/webtest RSYNC=/usr/bin/rsync LOG=/tmp/rsync_web.log WEBIP=192.168.1.73 #這是線上web伺服器IP export LANG=en_US.UTF-8 $SVN update $WEB --username svnadmin --password 123456 if [ $? == 0 ] echo "" >>$LOG echo `date` >> $LOG echo "#####################" >>$LOG $RSYNC -vaztpH --timeout=90 --exclude-from=/home/svn/webtest/exclude.list $web root@$WEBIP:/www/>>$LOG if #--exclude-from 可不要根據需求不同步的排除
[root@centos03 hooks]# chmod +x post-commit
http://darkyin.blog.51cto.com/6260426/1361132