Git WebHook(PHP)无法访问ruby环境,运行jekyll作为apache用户

7 apache git webhooks jekyll

post-merge我的git存储库中有一个挂钩,它只运行jekyll命令.

当我跑步时git pull,post-merge跑步没有问题.

但是,我已经设置了一个PHP文件,它将充当远程的WebHook:

$pull = `cd .. && git pull`;
echo $pull;
Run Code Online (Sandbox Code Playgroud)

当我访问此文件时,git pull运行(在一些初始问题之后)并且成功.但是,由于某种原因post-merge失败了.如果我查看我的Apache内部error_log,我发现以下错误:

.git/hooks/post-merge: line 5: jekyll: command not found

考虑到post-merge当我git pull通过SSH 做手册时成功运行jekyll ,这很奇怪.

如果我运行使用这里建议的可执行文件的完整路径,我在我的错误中收到此错误error_log:

/usr/bin/env: ruby_noexec_wrapper: No such file or directory

我通过RVM安装了Ruby.

如何让apache用户运行jekyll没有问题?

编辑:这是我目前的post-merge:

#!/bin/sh

unset GIT_DIR

source /usr/local/rvm/environments/ruby-1.9.3-p194

/usr/local/rvm/gems/ruby-1.9.3-p194/bin/jekyll

echo "Deployed!"
Run Code Online (Sandbox Code Playgroud)

当我以apache用户身份运行时,我现在收到此错误:

Node.js已安装.

小智 2

因为我使用的是 RVM,所以我必须直接获取它而不是 Ruby。不知道为什么,但它现在可以工作了。

\n\n

我的post-merge看起来像这样:

\n\n
#!/bin/bash\n\nunset GIT_DIR\n\n/usr/local/rvm/bin/rvm use 1.9.3\n\n/usr/local/rvm/gems/ruby-1.9.3-p194/bin/jekyll\n\necho "Deployed!"\n
Run Code Online (Sandbox Code Playgroud)\n\n

不完美的 \xe2\x80\x93 rvm 回显了一些我不想要的东西,但它有效。

\n