构建中央 Git 远程来为 Apache 生产站点提供服务
目前,我通过 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您将公共 ssh 密钥发布到目标帐户“
.ssh/authorized_keys
,则不需要“ 文件。例如,另请参阅锁定 ssh 授权密钥。
还有官方参考Pro Git 书籍“设置服务器”。
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".