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

标签 php git apache ubuntu vps

我的新 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/

相关文章:

git - 使用 TortoiseGit 时升级 Windows 版 Git?

git-review -> 将草稿提升为代码审查

apache - 将 ColdFusion 11 连接到远程 Solr

php - Azure 不会 cURL 谷歌站点搜索 xml

php - Laravel 查询生成器 - 查询不工作但在 SQL 控制台中工作

php - 如何在后台运行 PHP 的内置 Web 服务器?

Git参数管道脚本

PHP-FPM 和 Nginx : "Resource temporarily unavailable" errors in proxy_error_log

Php通过代理请求

java - Apache POI - 无法让折线图值出现在辅助轴中