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
I'm attempting to use simple-php-git-deploy to automatically update a test server when I commit changes to my git repo
When the below php script excerpt runs shell_exec('which git')
the function returns an empty string.
Since I can run git commands in SSH, I feel like this must be a permissions issue.
I tried running chmod 755 foldertoupdate
with no change.
What do I need to do to allow php (or the current apache user) to call git commands?
// 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]
);
}
}
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
As I can see, it's not about executing git from your code, but about executing shell programs (
which
, in this case). It is not clear if you are executing the deploy.php script via a browser or directly in the shell.Try to use
exec('command -v git', $output, $retval);
to checkgit
command availability in PHP interactive mode (php -a
) and see if this works there.Godaddy tech support confirmed that
php
does not have access togit
commands in their shared hosting environment. They said that VPS would be needed to achieve this.