Git错误:.git / FETCH_HEAD:权限被拒绝

  1. I did clone as apache user
  2. Created php file with exec("git pull origin master 2>&1", $out);

Terminal as root or as apache works fine: php auto_deploy.php

But http http://.../auto_deploy.php return error
error: cannot open .git/FETCH_HEAD: Permission denied

Folder owner and group are same "apache".

Chmod 777 does not help.

The main difference is, that when php file launched from HTTP it does not work, it feels like it knows that it is http and blocking it, because in terminal Apache user works perfect with git even launching php file.

For the use case you describe the Apache user will needs its SSH key approving so that it can access the remote repository.