PHP is used to process requests sent from github. The test is normal. It is always unsuccessful to call a script or execute a command using exec. {Code...} file_put_contents can write content, proving that the signature is matched successfully. The pull code can also be executed independently on the server. Scripts... Use PHP to process requests sent from github. The test is normal. It is always unsuccessful to call a script or execute a command using exec.
// Determine whether the signature matches if ($ hash = $ payloadHash) {// call shell // file_put_contents ('/var/www/niucunhui. io/auto/test.txt ', 'The program is here'); exec ('CD/var/www/niucunhui. io/auto/& git pull ');}
File_put_contents can write content to prove that the signature is matched successfully. The pull code can also be executed independently on the server.
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."
You can also run the exec () command to write a PHP program separately.
Is there a problem?
Server version: CentOS 6.5
PHP version 5.6.15
Reply content:
PHP is used to process requests sent from github. The test is normal. It is always unsuccessful to call a script or execute a command using exec.
// Determine whether the signature matches if ($ hash = $ payloadHash) {// call shell // file_put_contents ('/var/www/niucunhui. io/auto/test.txt ', 'The program is here'); exec ('CD/var/www/niucunhui. io/auto/& git pull ');}
File_put_contents can write content to prove that the signature is matched successfully. The pull code can also be executed independently on the server.
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."
You can also run the exec () command to write a PHP program separately.
Is there a problem?
Server version: CentOS 6.5
PHP version 5.6.15
Https://zhuzhenyu.org/2016/01/03/php-github-php/
The git command must be fully written.