php执行的系统用户为www
#打开文件
vim vim /etc/sudoers
#php执行git 命令,添加下行代码到文末
www localhost=(ALL) NOPASSWD:/usr/bin/git
#生成部署公钥
sudo -Hu www ssh-keygen -t rsa -C "625343614@qq.com"
#查看公钥,复制到公钥管理内
vim /home/www/.ssh/id_rsa.pub
#测试通过
ssh -T git@gitee.com
#git clone到本地
sudo -Hu www git clone git@gitee.com:wuxueshi/ngNote.git
#新建php文件update.php,内容如下
error_reporting(E_ALL);
echo '<pre>';
$res[] = shell_exec("cd /home/wwwroot/gitee/ngNote && /usr/bin/git pull");
var_dump($res);
#把{DOMAIN}/update.php复制到webHook对应位置