You are having a problem with the user here that is executing the command.
According to your various comments, the system commands are executed as the user named apache
(homedir is /var/www
). You can verify this by running the whoami
command from within your PHP script:
<?php echo `whoami`;
That user named apache
is commonly the user your webserver runs under, which then runs PHP which then runs the shell commands.
Obviously you want to run the command as some other user, but you have not shared so far the information which one.
Run the shell command under the right user and the problem should go away.
On a linux system, the command to run other commands under a different user is called sudo
, another one su
:
Alternatively you can make use of suexec to execute PHP under a different user than the webserver user.
In any case you need to ensure that you have a user that is able to execute the git command. I have no clue how you tested that on your own, best way I know is to ssh into the server box, do the git pull manually and collect the needed data like user-name, homedirectory etc. .
echo
cd .. && pwd`` and that seemed to work fine, but I’m not sure if safe mode being enabled would restrict me from doing that. I’ll have a look and post back here when I’ve found out. – Dentistryerror: cannot open .git/FETCH_HEAD: Permission denied
? – Dentistry