I prepared a PHP script that runs
shell_exec("git pull");
it was supposed to be a webhook for git repo run everytime there are changes pushed to the remote. After execution nothing happens, I get an empty response.
I changed the directories owner to "apache" (repo was cloned as "apache"). I've generated a key and uploaded it to bitbucket. It seems to work correctly, when I run
# sudo -u apache git pull
it works perfectly. Doesn't prompt with anything.
when I run
shell_exec("whoami");
I get "apache".
Is it possible that php is blocking git pull? When I run other git commands (like git status), I get the response.
UPDATE
when I do
shell_exec("git pull 2>&1");
it says
error: cannot open .git/FETCH_HEAD: Permission denied
I'm confused. I'm sure .git dirs and subdirs owner is apache and it has right priviliges to go...
UPDATE #2
I run
shell_exec("git --work-tree=/path/to/repo --git-dir=/path/to/repo/.git pull 2>&1");
and it still says
error: cannot open /path/to/repo/.git/FETCH_HEAD: Permission denied
no way! /path/to/repo/.git/FETCH_HEAD is readable by everyone!
I'm well confused.