用git pull的Shell_exec? [英] Shell_exec with git pull?

查看:165
本文介绍了用git pull的Shell_exec?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立一个github账户,与一些朋友一起开展一个小项目。
我希望我的家用机器能够通过php做一个git pull,这样我们只需要调用这个小型php文件来让机器保持最新。



截至目前:

 <?php 
$ output = shell_exec('git帮帮我');
echo< pre> $ output< / pre>;
?>

这个工作完美,我得到的输出,我在正确的目录,所以git拉应该工作同样的,但我得到一个挂页,没有错误,没有。



有什么想法吗?编辑:一些精度,回购是相当小的,大约300K,它只需要从命令行几秒钟。我也试过shell_exec(dir),我在正确的目录中。我在Windows 7 x64上运行xampp的默认安装,如果我可以足够精确的话:)

我建议探索< a href =http://php.net/manual/en/function.set-time-limit.php =nofollow noreferrer> set_time_limit(),以及确保你的git pull如果用户通过 ignore_user_abort()断开连接,则不会停止。即使是从千兆连接的服务器运行,一些存储库也需要一段时间才能克隆。

另外,请检查PHP的工作目录,确保用户运行PHP有权写入回购。如果你通过CLI运行这个程序并且它运行的很好,那么当你通过你使用的任何Web服务器访问PHP时,它很可能没有适当的权限运行。



如果你 chmod destionation目录为 777 ,它很有效,你需要重新编译apache / php为suexec支持。请不要把它留作777,如果是这样的话):

无论哪种方式,超时和用户异常终止仍然是有效的考虑因素,即使你得到它工作。


I am setting up a github account, to work on a small project with some friends. I would like to have my home machine able to do a git pull via php, so that we just have to call this small php file for the machine to be up to date.

As of right now :

<?php
$output = shell_exec('git help');
echo "<pre>$output</pre>";
?>

This works perfectly and I get the output, I am in the right directory, so git pull should work just as well, but I get a hanging page, no error, nothing.

Any idea ?

EDIT : A few precisions, the repo is pretty small, around 300K, it takes only a few seconds from the command line. I also tried shell_exec("dir"), and I am in the right directory. I am running the default installation of xampp on Windows 7 x64, if I can be precise enough :)

解决方案

I suggest exploring set_time_limit() , as well as making sure your git pull does not stop if the user disconnects via ignore_user_abort(). Even running from a gigabit connected server, some repositories just take a while to clone.

Also, check PHP's working directory, and ensure the user running PHP has privileges to write to the repo. If you ran this via CLI and it 'just works', its a good chance that PHP was running without appropriate privileges when accessed via whatever web server you are using.

If you chmod the destionation directory as 777 and it works, there's a very good chance that you need to recompile apache/php for suexec support. Please, don't just leave it as 777 if that is the case :)

Either way, time out and user aborts are still valid considerations, even after you get it working.

这篇关于用git pull的Shell_exec?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆