1.設定伺服器内腳本
vim gitpull.sh
#!/bin/bash
WEB_PATH='/server/web/ewms1'
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."
2.PHP方式拉取
vim gitpull.php
<?php
$rowData = file_get_contents('php://input', 'r');;
$rowData = json_decode($rowData,true);
exec('cd /server/work/ ; ./gitpull.sh',$out);
var_dump($out);
3.修改PHP.ini檔案
vim /usr/local/php/etc/php.ini
disable_functions = passthru,system,chroot,chgrp,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server
4.重加載PHP服務
systemctl restart php-fpm
源站部落格:git鈎子–PHP方式