git

远程更新git项目代码

1.添加 hook.php 脚本,记得 检查PHP的exec函数 是否被禁用 $web_root='/www/wwwroot/xxx.com'; //服务器 项目根目录地址 $shell = "cd {$web_root}/ && pwd && git pull 2>&1"; exec($shell,$out); print_r($out); 2.在代码管理…

1 阅读

1.添加 hook.php 脚本,记得 检查PHP的exec函数 是否被禁用 $web_root='/www/wwwroot/xxx.com'; //服务器 项目根目录地址 $shell = "cd {$web_root}/ && pwd && git pull 2>&1"; exec($shell,$out); print_r($out);

2.在代码管理库(gitea ,github)添加钩子,指向上面的php地址 http://xxx.com/hook.php

3.在服务添加 www 权限 cd ~ vi .git-credentials https://用户名:密码@gitee.com git config --global credential.helper store #执行成功后出现~/.gitconfig文件 cp ~/.gitconfig /home/www/ cp ~/.git-credentials /home/www/ cd /home/www chown www.www .gitconfig chown www.www .git-credentials

4.到你的项目下执行

chmod -R 777 .git

6.检查项目权限,如果不对

chown -R www.www  项目地址

5.用浏览器访问 http://xxx.com/hook.php 成功结果返回 Array ( [0] => /www/wwwroot/dcc.com [1] => Already up-to-date. )

正在加载评论…