Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

shell_exec configuration for git pull Godaddy vs Bluehost

I have a git pull web hook from Github, on two remotes, GoDaddy [production] and on Bluehost [staging]. This question isn't about those companies per se, but what could possibly be the reason for differences in the setups. I have this script, which I have setup as a post commit hook on github.com :

<?php
$output = shell_exec('git pull origin master');
echo "<pre>$output</pre>";
?>

When I commit on the Github repo, the hook fires and works fine on Bluehost. It doesn't do anything on Godaddy.

Bluehost browser response:

"already up to date". Pull command works, and the Bluehost repo is updated.

Godaddy browser response:

<pre></pre> Pull command has not worked. Repo not updated.

When I run this script via a browser:

<?php
$output = shell_exec('ls');
echo "<pre>$output</pre>";
?>

I get the proper 'ls' directory output on both servers.

When I SSH into the directory, I can manually issue the command 'git pull origin master' and it works on both servers. So does this just mean that Godaddy allows PHP to issue SOME commands, but not others? Can I fix this somehow? It can't be true that no one is automatically deploying into Godaddy!

like image 288
Jim Maguire Avatar asked Oct 14 '15 04:10

Jim Maguire


2 Answers

That could be similar to a previous case where:

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.

This comment confirms that php settings (that you can configure) are very limited on a shared server.

So check with the Godaddy support if thatis the case for your setup.

like image 90
VonC Avatar answered Nov 12 '22 22:11

VonC


I had a similar issue where the command I was running:

$output = shell_exec('git pull origin master');

Would return a blank string, though other git commands would not. This was resolved by adding 2>&1 to the end of the shell command:

$output = shell_exec('git pull origin master 2>&1');

This will redirect STDERR output to STDOUT, and I discovered git was throwing an error I could not see.

http://us3.php.net/manual/en/function.shell-exec.php#106250

http://www.tldp.org/LDP/abs/html/io-redirection.html

like image 23
Ben Avatar answered Nov 12 '22 23:11

Ben