shell_exec('git git')在Godaddy共享托管服务器上返回空字符串
我使用git和我的服务器(godaddy共享托管)设置了有关SSH密钥的所有内容,并且可以使用git pull git@github.com:username/reponame.git
I have everything setup with git and my server (godaddy shared hosting) regarding SSH keys and can update the server successfully via SSH with git pull git@github.com:username/reponame.git
我正在尝试使用简单php -git-deploy 以在我对git repo提交更改时自动更新测试服务器
I'm attempting to use simple-php-git-deploy to automatically update a test server when I commit changes to my git repo
当下面的php脚本摘录运行shell_exec('which git')
时,该函数返回一个空字符串.
When the below php script excerpt runs shell_exec('which git')
the function returns an empty string.
由于我可以在SSH中运行git命令,因此我觉得这一定是权限问题.
Since I can run git commands in SSH, I feel like this must be a permissions issue.
我尝试无变化地运行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
- The folder I'm updating is at
~/html/TeamBoard
- The file I'm calling the code from is at
~/html/TeamBoard/deploy.php
More Info:
Godaddy技术支持确认php
在其共享托管环境中无权访问git
命令.他们说,将需要VPS来实现这一目标.
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.