shell_exec('which git') returns Godaddy 共享主机服务器上的空字符串
shell_exec('which git') returns empty string on Godaddy shared hosting server
我已经使用 git 和我的服务器(godaddy 共享主机)设置了关于 SSH 密钥的所有设置,并且可以使用 git pull git@github.com:username/reponame.git
通过 SSH 成功更新服务器
我正在尝试使用 simple-php-git-deploy 在我对 git 存储库
提交更改时自动更新测试服务器
当下面的php脚本摘录运行s shell_exec('which git')
函数returns一个空字符串。
因为我可以在 SSH 中 运行 git 命令,所以我觉得这一定是权限问题。
我试过 运行宁 chmod 755 foldertoupdate
没有任何变化。
我需要做什么才能允许 php(或当前的 apache 用户)调用 git 命令?
// Check if the required programs are available
$requiredBinaries = array('git', 'rsync');
//.....
foreach ($requiredBinaries as $command) {
$path = trim(shell_exec('which '.$command));
if ($path == '') {
die(sprintf('<div class="error"><b>%s</b> not available. It needs to be installed on the server for this script to work.</div><br> Output was: %s', $command,$path )); // this check fails on the first element, "git" claiming git is not installed
} else {
$version = explode("\n", shell_exec($command.' --version'));
printf('<b>%s</b> : %s'."\n"
, $path
, $version[0]
);
}
}
更多信息:
- 我正在更新的文件夹位于
~/html/TeamBoard
- 我从中调用代码的文件位于
~/html/TeamBoard/deploy.php
Godaddy 技术支持确认 php
在其共享主机环境中无法访问 git
命令。他们说需要 VPS 才能实现这一目标。
如我所见,这不是关于从您的代码执行 git,而是关于执行 shell 程序(在本例中为 which
)。不清楚您是通过浏览器还是直接在 shell.
中执行 deploy.php 脚本
尝试使用 exec('command -v git', $output, $retval);
检查 git
命令在 PHP 交互模式下的可用性 (php -a
) 并查看它是否有效。
我已经使用 git 和我的服务器(godaddy 共享主机)设置了关于 SSH 密钥的所有设置,并且可以使用 git pull git@github.com:username/reponame.git
我正在尝试使用 simple-php-git-deploy 在我对 git 存储库
提交更改时自动更新测试服务器当下面的php脚本摘录运行s shell_exec('which git')
函数returns一个空字符串。
因为我可以在 SSH 中 运行 git 命令,所以我觉得这一定是权限问题。
我试过 运行宁 chmod 755 foldertoupdate
没有任何变化。
我需要做什么才能允许 php(或当前的 apache 用户)调用 git 命令?
// Check if the required programs are available
$requiredBinaries = array('git', 'rsync');
//.....
foreach ($requiredBinaries as $command) {
$path = trim(shell_exec('which '.$command));
if ($path == '') {
die(sprintf('<div class="error"><b>%s</b> not available. It needs to be installed on the server for this script to work.</div><br> Output was: %s', $command,$path )); // this check fails on the first element, "git" claiming git is not installed
} else {
$version = explode("\n", shell_exec($command.' --version'));
printf('<b>%s</b> : %s'."\n"
, $path
, $version[0]
);
}
}
更多信息:
- 我正在更新的文件夹位于
~/html/TeamBoard
- 我从中调用代码的文件位于
~/html/TeamBoard/deploy.php
Godaddy 技术支持确认 php
在其共享主机环境中无法访问 git
命令。他们说需要 VPS 才能实现这一目标。
如我所见,这不是关于从您的代码执行 git,而是关于执行 shell 程序(在本例中为 which
)。不清楚您是通过浏览器还是直接在 shell.
尝试使用 exec('command -v git', $output, $retval);
检查 git
命令在 PHP 交互模式下的可用性 (php -a
) 并查看它是否有效。