操作系统 – Ubuntu 14.04
我正在使用GIT webhooks进行部署.
我已经将部署密钥添加到git repo,现在我想在我的本地仓库发生推送时触发git pull origin master命令.
这是我通过浏览器调用的test.php文件:
//echo "THis is a test file on a test repo for testing the deploy functionality using github webhooks!!!!";
echo exec('whoami');
echo exec('sh -x /var/www/proj/test/git.sh');
?>
这是git.sh shell文件:
#!/bin/bash
cd /var/www/proj-dir/test
git pull origin master
当我使用php test.php在终端上运行它时,我得到了正常的结果:
ubuntu From github.com:repo/test
* branch master -> FETCH_HEAD
Already up-to-date.
ubuntu for whoami后跟git pull输出.
现在问题是当我通过浏览器调用相同的http://example.com/test.php它显示用户或whoami输出为www-data,这是apache用户,但我尝试更新php文件的权限执行和更改用户到www数据,但没有工作.
检查了apache日志,当我通过浏览器执行时,我收到了权限错误
Please make sure you have the correct access rights and the repository exists. + cd /var/www/proj/deploy-test + git pull origin master
主机密钥验证失败.致命:无法从远程存储库读取.请确保您具有正确的访问权限并且存储库存在.
我需要做什么更新,以便文件通过浏览器请求工作?
如果我需要更新sudoers文件应该更新什么?
更新
我将.ssh键添加到var / www / dir,因为它是apache用户的主页.但我仍然得到了
git pull origin master
error: cannot open .git/FETCH_HEAD: Permission denied
另外,我为www-data用户添加了一行,以便能够执行sh文件.
www-data ALL=(anthony) NOPASSWD: /var/www/mysite/vendor/tmd/auto-git-pull/scripts/git-pull.sh
参考here仍然没有运气
将.git文件夹的权限更新为www-data用户
sudo chown www-data:www-data /var/www/proj/test/.git