php实现webhook自动部署代码



简单利用coding结合git实现webhook

 

1.创建webhook.php

   确保服务器上能以ssh方式进行git pull操作

确保shell_exec能执行,在php.ini中 disable_functions 中去掉 shell_exec
php实现webhook自动部署代码
<?php

$pwd = getcwd();
$command = 'cd ' . $pwd . ' && git pull';
$output = shell_exec($command);
print $output;

?>
php实现webhook自动部署代码

2.设置权限

   linux服务器上项目默认权限是root用户,而用户访问webhook.php的权限是www,www是没有权限执行git pull操作的,所以需要改变项目所有者权限

chown -R www catalogue 

 

3.coding配置webhook设置

php实现webhook自动部署代码

简单利用coding结合git实现webhook

 

1.创建webhook.php

   确保服务器上能以ssh方式进行git pull操作

确保shell_exec能执行,在php.ini中 disable_functions 中去掉 shell_exec
php实现webhook自动部署代码
<?php

$pwd = getcwd();
$command = 'cd ' . $pwd . ' && git pull';
$output = shell_exec($command);
print $output;

?>
php实现webhook自动部署代码

2.设置权限

   linux服务器上项目默认权限是root用户,而用户访问webhook.php的权限是www,www是没有权限执行git pull操作的,所以需要改变项目所有者权限

chown -R www catalogue 

 

3.coding配置webhook设置

php实现webhook自动部署代码