本文介绍了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
  • More Info:

    • The folder I'm updating is at ~/html/TeamBoard
    • The file I'm calling the code from is at ~/html/TeamBoard/deploy.php
    • 推荐答案

      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.

      这篇关于shell_exec('git git')在Godaddy共享托管服务器上返回空字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 21:33