使用PHP处理github发送过来的请求,测试正常。在调用脚本或使用exec()执行命令总是不能成功。
1 2 3 4 5 6 7 8 | <code>
if ( $hash === $payloadHash ) {
exec ( 'cd /var/www/niucunhui.io/auto/ && git pull' );
}
</code>
|
登入後複製
登入後複製
file_put_contents可以写入内容,证明签名是匹配成功的。在服务器单独执行脚本,也是可以pull代码。
脚本如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | <code>#!/bin/bash
WEB_PATH= '/var/www/niucunhui.io/sql-optimize-referance/'
WEB_USER= 'www'
WEB_USERGROUP= 'www'
echo "Start deployment"
cd $WEB_PATH
echo "pulling source code..."
git reset --hard origin/master
git clean -f
git pull
git checkout master
echo "changing permissions..."
chown -R $WEB_USER : $WEB_USERGROUP $WEB_PATH
echo "Finished."
</code>
|
登入後複製
登入後複製
单独写一个PHP程序 exec()命令也是可以执行的。
请问,还有可能是那里的问题?
服务器版本 CentOS 6.5
PHP版本 5.6.15
回复内容:
使用PHP处理github发送过来的请求,测试正常。在调用脚本或使用exec()执行命令总是不能成功。
1 2 3 4 5 6 7 8 | <code>
if ( $hash === $payloadHash ) {
exec ( 'cd /var/www/niucunhui.io/auto/ && git pull' );
}
</code>
|
登入後複製
登入後複製
file_put_contents可以写入内容,证明签名是匹配成功的。在服务器单独执行脚本,也是可以pull代码。
脚本如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | <code>#!/bin/bash
WEB_PATH= '/var/www/niucunhui.io/sql-optimize-referance/'
WEB_USER= 'www'
WEB_USERGROUP= 'www'
echo "Start deployment"
cd $WEB_PATH
echo "pulling source code..."
git reset --hard origin/master
git clean -f
git pull
git checkout master
echo "changing permissions..."
chown -R $WEB_USER : $WEB_USERGROUP $WEB_PATH
echo "Finished."
</code>
|
登入後複製
登入後複製
单独写一个PHP程序 exec()命令也是可以执行的。
请问,还有可能是那里的问题?
服务器版本 CentOS 6.5
PHP版本 5.6.15
https://zhuzhenyu.org/2016/01/03/php-github-php/
git命令需要写全路径