【问题标题】:shell_exec configuration for git pull Godaddy vs Bluehostgit pull Godaddy vs Bluehost 的 shell_exec 配置
【发布时间】:2016-01-12 00:38:24
【问题描述】:

我有一个来自 Github 的 git pull web hook,在两个遥控器上,GoDaddy [production] 和 Bluehost [staging]。这个问题与这些公司本身无关,而可能是设置差异的原因。我有这个脚本,我在 github.com 上将它设置为提交后挂钩:

<?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,这不可能是真的!

【问题讨论】:

  • shell_exec 是否执行了某些操作?喜欢echols
  • 在 godaddy 或 VPS 上共享主机?

标签: git shared-hosting bluehost


【解决方案1】:

这可能类似于previous case,其中:

Godaddy 技术支持确认 php 在其共享主机环境中无法访问 git 命令
他们说需要 VPS 来实现这一点。

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

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

【讨论】:

  • 谢谢 VonC,我想这就是答案。由于我为这个问题支付了 50 分,我将在社论中说只有疯子才会使用 Godaddy 进行托管。我现在已经与这家公司打过交道,涉及 10 个不同的领域,涉及 10 个不同的客户。新规则:如果您想让 Jim 在您的网站上工作,必须将其从 Godaddy 移除。
【解决方案2】:

我在运行命令时遇到了类似的问题:

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

将返回一个空白字符串,尽管其他 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

【讨论】:

    猜你喜欢
    • 2011-02-01
    • 2011-07-05
    • 2018-08-21
    • 2020-03-25
    • 2021-11-17
    • 2023-02-26
    • 2013-11-06
    • 2017-12-07
    • 2019-12-12
    相关资源
    最近更新 更多