无法让github的webhook URL在我的服务器上运行

时间:2012-10-01 16:21:28

标签: git github centos

我的工作流程非常简单:

  1. 当地:
  2. mkdir testrepo && git init && git add . && git commit -m 'commit X' && git push -u origin master

    一切都很好,我的github回购更新。

    1. dev server:
    2. git clone github_repo_url

      我按照here的说明设置了一个post post hook。

      当我从本地推送更改时,repo会更新,但我在<?php git pull的服务器端的脚本不起作用。如果我ssh服务器并使用php github.php执行它,脚本确实执行git pull并且服务器上的文件正在更新。

      我也试过<?php $output = shell_exec('git pull'); echo $output;,但同样的事情。我推,repo得到更新,即使后接收挂钩设置正确,开发服务器也不会拉(我可以通过RequestBin看到)。

      github.php - 755权限。但是,所有者不是root用户,如果我执行chown username:group github.php,则会收到500错误。

      如果/当我运行脚本时,它不会要求输入密码,没有可以阻止脚本的对话框..我根本就没有得到它。

      git pull上以root身份手动记录,而在该目录中的ssh上:

      git pull
      remote: Counting objects: 5, done.
      remote: Compressing objects: 100% (2/2), done.
      remote: Total 3 (delta 0), reused 3 (delta 0)
      Unpacking objects: 100% (3/3), done.
      From github.com:test/testrepo
         0e678d9..88b3237  master     -> origin/master
      Updating 0e678d9..88b3237
      Fast-forward
       test.html |    2 +-
       1 files changed, 1 insertions(+), 1 deletions(-)
      root@echo [/home/username/public_html/dev/testrepo]# 
      

      完成工作。我的文件已更新。

      有任何想法吗?

      难道apache本身不能运行php脚本吗?此外,如果我ssh到服务器而不是root,我尝试运行PHP脚本,我得到一个Permission denied(publickey)。致命:远程端意外挂断

2 个答案:

答案 0 :(得分:4)

您可能尝试的另一件事是通过https将您的用户名和密码设置为

  

https://username:password@github.com/user/reponame.git

这样您就不必实际SSH了。这是从远程repo服务器拉出来的时候。添加遥控器时,请确保添加这些参数。

否则,在服务器上创建一个ssh密钥,并将其与GitHub作为Deploy Key链接。确保在创建ssh密钥时没有输入密码。否则,您将遇到与现在相同的问题,因为它没有通过身份验证阶段。

答案 1 :(得分:3)

这是因为当你不做“git pull”时,必须输入密码。当您登录(ssh)时,我认为您无权访问密码。请看这个链接:http://wiki.mediatemple.net/w/(gs):GitHub

此链接指导:http://seancoates.com/blogs/deploy-on-push-from-github

相关问题