shell_exec and git pull

浪尽此生 提交于 2019-12-03 09:13:36
Mark Longair

From your description in the comments it seems that the problem is that your apache user cannot write to the repository, which is clearly required when you use git pull. You have two courses of action:

  1. Setup up Apache to run the script as another user (e.g. using suEXEC either on a VirtualHost or via userdir)
  2. Change the permissions on your repository so the apache user can write to it

You should think carefully about the security implications of either choice, but the second option is probably easiest. If you don't already have such a group, you can create it with:

addgroup gitwriters

... and then add yourself and the Apache user to this group:

adduser [yourusername] gitwriters
adduser apache gitwriters

Then you can follow the instructions in another question to change the permissions on the repository. To reiterate those with some slight variations:

# Recursively, set the group ownership of every file and directory of your repository:
chgrp -R gitwriters /path/to/your/repo

# Recursively, make every file and directory of your repository readable and writable
# by the group:
chmod -R g+rw /path/to/your/repo

# Recursively, set the setgid of every directory in the repository.  The setgid bit
# on directories means that files created in the directory will have the same group
# ownership as the directory.  
find /path/to/your/repo -type d -print0 | xargs -0 chmod g+s

Then hopefully your git pull should work.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!