I have my apache2 webserver directory as a Git directory, so when me and my team members (school project) make changes to our GitHub folder, it can easily be pulled by running 'git pull' in putty.
I want to make this automatic (using a WebHook) by having a "pull.php" file that has "<?php exec("git pull"); <?" inside it.
However, the user that shows up when I run whoami function in php is "www-data".
In order to allow www-data to run git pull without having to enter credentials (I tried setting up SSH and it refused to work), I need to allow them to store credentials.
This is problematic because unlike other users, www-data has no directory in /home/accountname to save its .gitconfig to.
How do I go about having "git credential.helper store" work for www-data?
I would also not mind having SSH, but I run into the same problem where the default directory to save the id_rsa file to says no permission/does not exist, so I would prefer the previous question to be answered.
CodePudding user response:
You have a similar issue in WordOps/WordOps #305
www-data user cannot write anything in
/var/wwwbecause this directory's owner isroot. So you can create the.gitconfigfile as root, and then change owner and permissions (following this recommendation) withchown www-data:www-data /var/www/.gitconfig chmod 644 /var/www/.gitconfig.Or you can change
/var/wwwdirectory owner (chown www-data /var/www) to allowwww-datato create files in this directory.
