Git WebHook不会拉(PHP) [英] Git WebHook will not pull (PHP)

查看:74
本文介绍了Git WebHook不会拉(PHP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个PHP文件, hook.php ,看起来像这样:


<?php
`cd ..&& git pull`;



该文件位于 /var/www/oliverash.me/site / 。然而,需要被拉的git仓库是 /var/www/oliverash.me / ./ site 是Apache看起来像文档根目录的文件夹。



当我在浏览器中运行文件时,它似乎并没有拉动存储库。



我也试着回应结果,但页面是空白的。




<?php
echo`cd ..&& git pull`;

解决方案

我无法发表评论回复您,但我我假设你正在运行一个* nix系统。如果您的apache / php守护进程没有访问 .git / 的权限,您将获得拒绝权限。您可以递归地更改 .git / 目录的所有者/组。或者做一个 chmod -R o + rw .git / * 给每个人(即不是所有者,不是组),读写git目录,清除您正在获取的权限错误。

编辑
请重新阅读这个问题,因此可能不需要,但为了以防万一。



尽管如此,您需要记住任何有权访问您的服务器的人都可以访问 http:// myurl /.git/ 等来访问这些。所以为了安全起见,我会添加一个 .htaccess 文件,如:

 在de 中拒绝,允许
拒绝所有

.git 目录,这样apache将拒绝来自Web浏览器的访问。


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

<?php `cd .. && git pull`;

The file is located in /var/www/oliverash.me/site/. However, the git repository that needs to be pulled is /var/www/oliverash.me/. ./site is the folder Apache looks to as the document root.

When I run the file in my browser, it does not seem to be pulling the repository.

I have also tried to echo the result, but the page is blank.

<?php echo `cd .. && git pull`;

解决方案

I can't post a comment in reply to you, but I am assuming that you are running a *nix system. You will be getting a permission denied if your apache/php daemons don't have permission to access .git/. You can change the owner/group of the .git/ directory recursively. Or do a chmod -R o+rw .git/* to give everyone (ie, not owner, not group) access to read and write in the git directory, which should clear up the permissions error that you are getting.

EDIT Just re-read the question, so what follows probably isn't needed, but leaving it just in case.

Though, doing that, you need to keep in mind that anyone with access to your server will be able to go to http://myurl/.git/ etc to access those. So as a security precaution, I would add a .htaccess file like:

order deny, allow
deny from all

in the.git directory so that apache will deny access from a web browser to everything in there.

这篇关于Git WebHook不会拉(PHP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆