使用php处理github发送过来的请求,测试正常。在调用脚本或使用exec()执行命令总是不能成功。
// 判断签名是否匹配
if ($hash === $payloadHash) {
// 调用shell
// file_put_contents('/var/www/niucunhui.io/auto/test.txt', '程序走到这里了');
exec('cd /var/www/niucunhui.io/auto/ && git pull');
}
file_put_contents可以写入内容,证明签名是匹配成功的。在服务器单独执行脚本,也是可以pull代码。
脚本如下:
#!/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."
单独写一个PHP程序 exec()命令也是可以执行的。
请问,还有可能是那里的问题?
服务器版本 CentOS 6.5
PHP版本 5.6.15
回复内容:
使用php处理github发送过来的请求,测试正常。在调用脚本或使用exec()执行命令总是不能成功。
// 判断签名是否匹配
if ($hash === $payloadHash) {
// 调用shell
// file_put_contents('/var/www/niucunhui.io/auto/test.txt', '程序走到这里了');
exec('cd /var/www/niucunhui.io/auto/ && git pull');
}
file_put_contents可以写入内容,证明签名是匹配成功的。在服务器单独执行脚本,也是可以pull代码。
脚本如下:
#!/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."
单独写一个PHP程序 exec()命令也是可以执行的。
请问,还有可能是那里的问题?
服务器版本 CentOS 6.5
PHP版本 5.6.15
https://zhuzhenyu.org/2016/01/03/php-github-php/
git命令需要写全路径











