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萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章