它在我的共享主机上运行良好,但在我的 VPS 上它返回 null 并且没有-6ren">
gpt4 book ai didi

php - Apache 允许 php 运行 `git pull`

转载 作者:行者123 更新时间:2023-12-04 19:19:41 25 4
gpt4 key购买 nike

我的新 VPS 遇到了麻烦。我创建了一个文件 pull.php在我的 GIT 文件夹中使用此代码:

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

它在我的共享主机上运行良好,但在我的 VPS 上它返回 null 并且没有执行“pull ”命令。当我将命令 'git pull' 更改为 'git status' 时,它会显示结果:

On branch master Your branch is up-to-date with 'origin/master'.

Untracked files: (use "git add ..." to include in what will be committed)

info.php pull.php test.txt

nothing added to commit but untracked files present (use "git add" to track)



我的文件夹 chmod 到 777 和 php 似乎可以正确写入。 SSH 上的“git pull”没问题。我的服务器:Ubuntu 14.x、Apache2、php5

我将非常感谢任何帮助!

最佳答案

可能 git pull 会引发错误,但默认情况下不会打印错误。要解决此问题,请更改此行

$output = shell_exec('git pull');

对于这个:
$output = shell_exec('git pull 2>&1');

关于php - Apache 允许 php 运行 `git pull`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24421568/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com