shell_exec git 的配置 pull Godaddy vs Bluehost

shell_exec configuration for git pull Godaddy vs Bluehost

我有一个 git 从 Github 拉网络挂钩,在两个遥控器上,GoDaddy [production] 和 Bluehost [staging]。这个问题与这些公司本身无关,但可能是设置差异的原因。我有这个脚本,我已将其设置为 github.com 上的 post 提交挂钩:

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

当我提交 Github 回购协议时,钩子会触发并在 Bluehost 上正常工作。它对 Godaddy 没有任何作用。

Bluehost 浏览器响应:

"already up to date". Pull command works, and the Bluehost repo is updated.

Godaddy 浏览器响应:

<pre></pre> Pull command has not worked. Repo not updated.

当我通过浏览器 运行 这个脚本时:

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

我在两台服务器上都获得了正确的 'ls' 目录输出。

当我通过 SSH 进入目录时,我可以手动发出命令 'git pull origin master',它在两台服务器上都有效。那么这是否仅仅意味着 Godaddy 允许 PHP 发出某些命令,而不是其他命令?我能以某种方式解决这个问题吗?没有人自动部署到 Godaddy 是不可能的!

这可能类似于 其中:

Godaddy tech support confirmed that php does not have access to git commands in their shared hosting environment.
They said that VPS would be needed to achieve this.

This comment 确认 php 设置(您可以配置)在共享服务器上非常有限。

如果您的设置属于这种情况,请咨询 Godaddy 支持人员。

我有一个类似的问题,我的命令是 运行:

$output = shell_exec('git pull origin master');

会 return 一个空字符串,尽管其他 git 命令不会。通过在 shell 命令的末尾添加 2>&1 解决了这个问题:

$output = shell_exec('git pull origin master 2>&1');

这会将 STDERR 输出重定向到 STDOUT,我发现 git 抛出了一个我看不到的错误。

http://us3.php.net/manual/en/function.shell-exec.php#106250

http://www.tldp.org/LDP/abs/html/io-redirection.html