Using PHP to handle requests sent by GitHub, the test is normal. Executing commands in the call script or using EXEC () is always unsuccessful.
// 判断签名是否匹配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 can write to the content to prove that the signature was successfully matched. It is also possible to pull code when the server executes the script separately.
The script is as follows:
#!/bin/bashWEB_PATH='/var/www/niucunhui.io/sql-optimize-referance/'WEB_USER='www'WEB_USERGROUP='www'echo "Start deployment"cd $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."
It is also possible to write a single PHP program exec () command.
Excuse me, is it possible that there is a problem?
Server version CentOS 6.5
PHP version 5.6.15
Reply content:
Using PHP to handle requests sent by GitHub, the test is normal. Executing commands in the call script or using EXEC () is always unsuccessful.
// 判断签名是否匹配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 can write to the content to prove that the signature was successfully matched. It is also possible to pull code when the server executes the script separately.
The script is as follows:
#!/bin/bashWEB_PATH='/var/www/niucunhui.io/sql-optimize-referance/'WEB_USER='www'WEB_USERGROUP='www'echo "Start deployment"cd $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."
It is also possible to write a single PHP program exec () command.
Excuse me, is it possible that there is a problem?
Server version CentOS 6.5
PHP version 5.6.15
https://zhuzhenyu.org/2016/01/03/php-github-php/
git commands need to write full path