shell_exec configuration for git pull Godaddy vs Bluehost
Asked Answered
A

2

9

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!

Ahrens answered 14/10, 2015 at 4:24 Comment(2)
does shell_exec executes something at all? like echo or ls?Jettiejettison
shared host at godaddy or VPS?Beverly
G
8

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.

Gerhart answered 13/11, 2015 at 13:33 Comment(1)
Thanks VonC, I guess that's the answer. Since I paid 50 points for this question, I'm gonna editorialize and say that only an insane person would use Godaddy for hosting. I have now dealt with this company across about 10 different domains, for 10 different clients. New rule: If you want Jim to work on your website, it MUST be taken off Godaddy.Ahrens
B
1

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.

https://www.php.net/manual/en/function.shell-exec.php#106250

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

Batting answered 21/1, 2016 at 1:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.