Git WebHook will not pull (PHP)

前端 未结 4 911
[愿得一人]
[愿得一人] 2021-01-16 03:35

I have a PHP file, hook.php, that looks like this:

The file is located in /var/www/ol

4条回答
  •  悲哀的现实
    2021-01-16 04:04

    You've certainly got a permissions issue, maybe a couple.

    1. The php page is going to execute as the apache user
    2. That user must be able to write to the git repo in question
    3. That user must be able to do the pull in question
    4. You didn't specify what the source of the pull is, but if it's, for instance, a git: or ssh: repo, then that user will need perms (keys, username/password, whatever) to access the remote to do the pull from.
    5. Just saw that it wants /var/www/.ssh - so you're using a ssh:// remote, which is fine, but since it's running as user apache (/var/www is user apache's homedir), it's looking for keys in /var/www/.ssh, which it's not finding, hence the failure. Solutions:
      1. use sudo to switch to a user that does have perms and run the git pull as that user (in your php, do 'sudo git pull', and in your /etc/sudoers put a line allowing user apache to run the 'git pull' command)
      2. set up a .ssh/config file that specifies a Host that's the remote, a User to use to login, and an Identity that is the path to the private key that the remote will allow to ssh in and do the pull.

提交回复
热议问题