shell_exec configuration for git pull Godaddy vs Bluehost

本小妞迷上赌 提交于 2019-12-22 04:31:40

问题


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!


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/33116607/shell-exec-configuration-for-git-pull-godaddy-vs-bluehost

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!