linux - 使用 Git 自动部署

标签 linux apache git deployment

我想知道是否有人针对这种情况有更好的策略。

我目前在与网络服务器相同的机器上托管我自己的远程 git 存储库。

所有git repos 都在git 用户下。

sudo -uwww-data -gwww-data git --git-dir=/var/www/website/.git --work-tree=/var/www/website pull

我有一个 cron 作业每分钟以 root 身份运行以执行此命令。 web 文件夹中的 git repo 从同一个盒子克隆到 git 的主目录,而不是通过 ssh 存储它。

所以我的问题是:由于 git 不拥有 web 文件,因此它无法使用 git hook 移动站点。我会假设我不希望 git 有 sudo,也不会通过 git hook 工作,对吧?有没有什么东西可以比每分钟更快地部署站点?我不希望手术非常昂贵。

是否有某种根守护进程可以运行并监听某种通知?比如让它查看文件的最后修改时间?

最佳答案

请注意 this article (in French, translated through Google) sudo 与您的方法配合使用的报告:

change sudo to allow the gitosis user to use this command as www-data.
To do this, by running "visudo" add the line:

git ALL = (www-data) NOPASSWD: /usr/local/bin/pullhere

Then, in each repository where necessary, add the next hook in a post-receive file:

sudo -u www-data /usr/local/bin/pullhere /html/u/user/here

eg in / home/git/repositories/projet1.git/hooks/post-receive

关于linux - 使用 Git 自动部署,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9061067/

相关文章:

c - Linux : pipeline output of one program to another

apache - 启用ssl后无法访问网站

git - 在 Ubuntu 中从源存储库升级 git

windows - 如何将 gVim 设置为 Git for Windows 上的编辑器?

git - 如何在 git 中仅将当前分支从本地推送到远程仓库?

php - Laravel View 在 Linux 服务器上不工作

sql-server - Microsoft SQL Server vNext – Linux 版 – 它缺少哪些 SQL Server 功能?

c++ - Linux套接字程序只是卡住而没有错误

c - 无法识别指令名称 "SCGIMount"

Eclipse Map and Reduce 插件和 Hadoop 教程