php实现webhook自动部署代码

 

 

 

 

简单利用coding结合git实现webhook

 

1.创建webhook.php

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

确保shell_exec能执行,在php.ini中 disable_functions 中去掉 shell_exec
<?php

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

?>

2.设置权限

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

chown -R www:www catalogue 

 

3.coding配置webhook设置

发布了40 篇原创文章 · 获赞 8 · 访问量 4万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章