[文章作者:张宴 本文版本:v1.0 最后修改:2008.10.06 转载请注明原文链接:http://blog.zyan.cc/read.php/371.htm]

  今天花几分钟写的一个PHP小程序,用途是:无需给程序员开放服务器SSH帐号,只需通过Web浏览器即可从SVN版本库更新代码到Linux服务器的指定目录。如果有需要,可以给这段代码加个密码登录。

  1、假设www、www是Apache或Nginx服务器的用户名和组,/data0/www/是网页文件存放根目录,执行以下shell命令:
sudo -s
/usr/sbin/groupadd www -g 48
/usr/sbin/useradd -u 48 -g www www
mkdir -p /data0/www/
chown -R www:www /data0/www/
su www
cd /data0/www/
/usr/local/bin/svn checkout --username zhangyan --password 123456 http://xxx.xxx.xxx.xxx:8080/svn/web/trunk/


  2、创建文件svn_up.php:

  3、通过浏览器访问svn_up.php,显示以下内容(例):
  U    /data0/www/app/DataTransferService.php
  Updated to revision 561.



Tags: , ,



技术大类 » 其他Unix技术 | 评论(59) | 引用(1) | 阅读(68183)
xi2008wang
2008-10-6 23:45
沙发, 这次看懂了zan
ohyeah
2008-10-7 21:44
感谢分享~

$handle = popen(\'/usr/local/bin/svn up --username zhangyan --password 123456 /data0/www/*\', \'r\');

后面的那个 * 没有必要加上吧?

有你blog在firefox下alert提示是乱码的
jason
2008-10-8 09:22
会不会产生.svn文件夹?
cloudchen
2008-10-8 11:12
用svn export就不会有.svn目录了
starhycold
2008-10-9 10:05
小技巧, 但是挺实用的.
larryli
2008-12-17 11:18
用 svn 钩子更方便
post-commit 监视指定目录,然后 up 就可以了
pl
2009-7-13 21:08
如果svn服务器与拷贝不在一起,钩子不会用。
烨勇
2010-1-19 11:08
我为什么在网页里不输出任何信息

<?php
$handle = popen('/usr/bin/svn update --username *** --password *** /data/nginx/htdocs/','r');
$read = stream_get_contents($handle);
echo "<pre>";
printf ($read);
echo "</pre>";
//pclose($handle);
?>
Jason-MT
2010-2-9 09:31
@烨勇
你有没先做/usr/local/bin/svn checkout --username zhangyan --password 123456 http://xxx.xxx.xxx.xxx:8080/svn/web/trunk/
这一步,作了这一步后,往后你调update命令,svn会知道去那个源取代码来更新!
游客
2010-3-5 15:07
烨勇 2010-1-19 11:08
我为什么在网页里不输出任何信息

遇到错误中断了,没执行到现实内容的那行代码
看看错误日志,肯定报错了
DANNY
2011-8-24 18:15
请问,写宴兄,我面APACHE下模块化下运行PHP就是不能执行POPEN函数,有什么解决办法吗?原因应该是权限不够
Hogan
2012-5-10 18:13
Ci sono diversi motivi principali per cui si può sicuramente trovare sul proprio volere le soluzioni contabili che coinvolgono tutta Stansted, anche se alcune persone potrebbero uomini e donne, probabilmente si dovrà disporre di soluzioni contabili rispetto con la gente. Stai con me per scoprire di più su molti dei motivi per prendere in considerazione l'impiego contabili in tutta Hogan Stansted. Costruire un businessIf vi capita di essere in funzione, è abbastanza possibile che si può fare uso di soluzioni contabili. Non date per scontato tutte le società hanno abbastanza soldi per utilizzare a tempo pieno il personale fiscali, così utilizzando una conditi insieme con l'agenzia affidabile che coinvolge tutta commercialisti Stansted potrebbe rendere meno difficili problemi.
coach factory outlet Email Homepage
2012-5-17 11:47
Today, following half a century, mentor leather-bases coach factory outlet continues to be the delicate craft of leather-based master is accountable for,Would you like to meet more friends, or go with the times? If yes, coach factory online is opening welcome doors to you.in the market you definitely can find various colorways that are designed in as well as the high quality that applied in. For most of you would like to come. So just come to our coach factory outlet online store to choose one.
louis vuitton sale Email Homepage
2012-5-17 11:47
Louis Vuitton belt at louis vuitton sale is one kind of fashion accessory with high cost performance among the Louis Vuitton accessories.Offering quality LV products with favorable prices, louis vuitton outlet store is at your service. Hurry up, or you can not seize the chance.in fact, louis vuitton is one of the most famous fashion design master.he opened the fist suitcase shop called after his name.
coach outlet online Email Homepage
2012-5-17 11:47
I heard of coach outlet online through the advertisement when I was shopping. And now I often brow the webpage and buy Coach bags online.It is a symbol regarding position not to mention nature.Here I would like to launch a excellent bags pertaining to business men.Which may be coach outlet store.coach outlet has always been simple,durable style features to win consumers.The products are more flexible,with easy bleaching,wear characteristics,and simply use a damp cloth.
coach outlet, Email Homepage
2012-5-17 11:47
Remember the coach outlet provide coach bags which won't be deteriorated into its overall styles by any means. It will maintain its looks, colors, and uniqueness for long time.coach outlet store online has been voted by Hour Detroit magazine readers as the Best of Detroit in their 12th annual readers'poll.Lots of women like which usually amount normally include a coach outlet online ,it provides coziness to many girls that don't even think it is a great bushel of great interest directly to them.
xujie777 Email
2012-5-18 16:59
We aim to make all our customers satisfy with our products. You will find a variety of Men's fashion louis vuitton uk, fashion Women's cheap Louis Vuitton bags in our store at affordable price.Thinking of interesting ways to cost a milestone birthday? louis vuitton online shop had one of the most distinctive distinctive celebrations.bakery along with living room operated by means of about three moment louis vuitton online Most effective Pastry Chef’s of the year Rammy Nominee Chef’s.
xujie777 Email
2012-5-18 16:59
The choices are likely to be basically countless seeing that louis vuitton outlet occurs with the help of completely new and also incredible concepts once in a while.Louis vuitton Wholesale Monogram Canvas HandbagsLouis Vuitton Collection Beach Handbags louis vuitton bags outlet Damier Canvas HandbagsLouis vuitton Mahina HandbagsLouis Vuitton Monogram Mini Lin HandbagsLouis Vuitton Monogram Multicolore HandbagsLouis vuitton Monogram Vernis HandbagsLouis Vuitton Wholesale Epi Leather HandbagsLouis Vuitton For Men HandbagsLouis Vuitton Damier Canvas WalletsLouis Vuitton Epi Leather WalletsLouis Vuitton Monogram Canvas WalletsLouis Vuitton Monogram Vernis WalleLouis Vuitton ShoesLouis Vuitton Men wallets.As the Authentic Louis Vuitton are so high-priced, so came the louis vuitton handbags outlet.
xujie777 Email
2012-5-18 16:59
coach outlet has become a popular shopping experience for consumers around the world, and a desirable distribution channel for manufacturer's and retailers.Getting your hands on coach outlet store online can be a hefty investment of hundreds of dollars.But do not despair,the Coach Outlet store could be the answer to your prayers.coach outlet online is your smart choice when you want to get the discount Coach accessory. You can find the exact Coach Bags and other accessory you want at a low price that's right for you. My dear friends, let the coach outlet online pave your way into the world of high fashion with their ultimate fashion factory.
xujie123
2012-5-21 11:25
Our online store offers you discounted Designer louis vuitton replica wallet at present. You could find them in desirable quality and price. If you don't mind high class louis vuitton uk, have a good time here.louis vuitton Store Online Handbags can also bring great accuracy as well as practical applicability and fashionable.Have you ever dreamed of being as charming as Madonna? Have you ever thought of becoming an envy of all your friends? If so, come to louis vuitton outlet.<br/>
分页: 1/3 第一页 1 2 3 下页 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]