// 判断签名是否匹配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/bashweb_path='/var/www/niucunhui.io/sql-optimize-referance/'web_user='www'web_usergroup='www'echo start deploymentcd $web_pathecho pulling source code...git reset --hard origin/mastergit clean -fgit pullgit checkout masterecho changing permissions...chown -r $web_user:$web_usergroup $web_pathecho 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/bashweb_path='/var/www/niucunhui.io/sql-optimize-referance/'web_user='www'web_usergroup='www'echo start deploymentcd $web_pathecho pulling source code...git reset --hard origin/mastergit clean -fgit pullgit checkout masterecho changing permissions...chown -r $web_user:$web_usergroup $web_pathecho finished.
单独写一个php程序 exec()命令也是可以执行的。
请问,还有可能是那里的问题?
服务器版本 centos 6.5
php版本 5.6.15
https://zhuzhenyu.org/2016/01/03/php-github-php/
git命令需要写全路径