构建中央 Git 远程来为 Apache 生产站点提供服务

发布于 2024-09-19 07:12:57 字数 1435 浏览 2 评论 0原文

我一直在参考 http://toroid.org/ams/git-website-howto< /a> 作为在托管 VPS 上运行的生产 Web 服务器的起点。 VPS 运行 cPanel 和 WHM,并且最终将托管多个客户端网站,每个客户端网站都有自己的 cPanel 帐户(因此,每个网站都有自己的 Linux 用户和主目录,为网站提供服务)。每个客户的站点都是一个单独的 Git 存储库。

目前,我通过 SSH 将每个存储库推送到客户端主文件夹中的裸存储库,例如 /home/username/git/repository.git/。根据上面的教程,每个存储库都已配置为通过 post-receive 挂钩检出到另一个目录。在这种情况下,每个存储库都会检出自己的 /home/username/public_html (新 cPanel 帐户的默认 DocumentRoot),然后由 Apache 提供文件。虽然这有效,但它要求我(在我的本地开发环境中)设置我的遥控器,如下所示:

url = ssh://[email protected]/home/username/git/repository.git/

它还要求我每次推送时都输入用户密码,这不太理想。

为了将所有存储库集中在一个文件夹中,我还尝试以 root 身份推送到 /root/git/repository.git ,然后从那里签出到相应的主目录。然而,这会导致所有签出的文件都归 root 所有,从而阻止 Apache 为该站点提供服务,并出现类似错误

[error] [client xx.xx.xx.xx] SoftException in Application.cpp:357: UID of script "/home/username/public_html/index.php" is smaller than min_uid

(据我所知,这是文件所有权/权限问题)

我可以解决 每个存储库的 post-receive 挂钩中的 chown 和 chgrp 命令的问题 - 然而,这也在我的脑海中引发了“不太正确”的标志。我还考虑过 gitosis (将我的所有存储库集中在 /home/git/ 中),但我认为我会遇到相同的文件所有权问题,因为签出的文件将由 git 用户拥有。

我是否以错误的方式处理这整件事?我觉得我完全缺少第三种更优雅的解决方案来解决整个问题。或者我应该坚持使用上面描述的方法之一?

I've been referring to http://toroid.org/ams/git-website-howto as a starting point for a production web server running on a managed VPS. The VPS runs cPanel and WHM, and it will eventually host multiple client websites, each with its own cPanel account (thus, each with its own Linux user and home directory from which sites are served). Each client's site is a separate Git repository.

Currently, I'm pushing each repository via SSH to a bare repo in the client's home folder, e.g. /home/username/git/repository.git/. As per the tutorial above, each repo has been configured to checkout to another directory via a post-receive hook. In this case, each repo checks out to its own /home/username/public_html (the default DocumentRoot for new cPanel accounts), where the files are then served by Apache. While this works, it requires me to set up (in my local development environment) my remotes like this:

url = ssh://[email protected]/home/username/git/repository.git/

It also requires me to enter the user's password every time I push to it, which is less than ideal.

In an attempt to centralize all of my repositories in one folder, I also tried pushing to /root/git/repository.git as root and then checking out to the appropriate home directory from there. However, this causes all of the checked-out files to be owned by root, which prevents Apache from serving the site, with errors like

[error] [client xx.xx.xx.xx] SoftException in Application.cpp:357: UID of script "/home/username/public_html/index.php" is smaller than min_uid

(which is a file ownership/permissions issue, as far as I can tell)

I can solve that problem with chown and chgrp commands in each repo's post-receive hook--however, that also raises the "not quite right" flag in my head. I've also considered gitosis (to centralize all my repos in /home/git/), but I assume that I'd run into the same file ownership problem, since the checked-out files would then be owned by the git user.

Am I just approaching this entire thing the wrong way? I feel like I'm completely missing a third, more elegant solution to the overall problem. Or should I just stick to one of the methods I described above?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

握住你手 2024-09-26 07:13:05

它还要求我每次推送时都输入用户密码,这不太理想

如果您将公共 ssh 密钥发布到目标帐户“.ssh/authorized_keys,则不需要“ 文件。

例如,另请参阅锁定 ssh 授权密钥
还有官方参考Pro Git 书籍“设置服务器”

It also requires me to enter the user's password every time I push to it, which is less than ideal

It shouldn't be necessary if you publish your public ssh key to the destintion account ".ssh/authorized_keys" file.

See also locking down ssh authorized keys for instance.
But also the official reference Pro Git Book "Setting Up the Server".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文