【问题标题】:Setup git over http/https with apache 2.4 server使用 apache 2.4 服务器通过 http/https 设置 git
【发布时间】:2016-03-27 01:35:35
【问题描述】:

我正在尝试在 apache 2.4 后面设置一个 git 服务器,但无法让它工作。我尝试遵循我在这里找到的所有提示,但没有找到适用于 linux 的有效配置。我确实找到了适用于 windows 的配置,但是当我尝试对其进行调整时,它仍然失败。

这个想法是从https://example.com/git/test.git访问存储库

这是我的 apache2.conf 中与我的 git 配置相关的部分:

<Directory "/var/www/kh_webserver/git">
AuthType Basic
AuthName "Git Repository"
AuthUserFile /etc/apache2/git.passwds
Require valid-user
</Directory>

SetEnv GIT_PROJECT_ROOT /var/www/kh_webserver/git
SetEnv GIT_HTTP_EXPORT_ALL true
SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER
ScriptAliasMatch \
    "(?x)^/git/(.*/(HEAD | \
                info/refs | \
                objects/(info/[^/]+ | \
                         [0-9a-f]{2}/[0-9a-f]{38} | \
                         pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
                git-(upload|receive)-pack))$" \
                "/usr/lib/git-core/git-http-backend/$1"


<LocationMatch "^/git/.*/git-receive-pack$">
Options +ExecCGI
AuthType Basic
AuthName "Restricted Access"
AuthUserFile /etc/apache2/git.passwds
Require valid-user
</LocationMatch>

<LocationMatch "^/git/.*/git-upload-pack$">
Options +ExecCGI
AuthType Basic
AuthName "Restricted Access"
AuthUserFile /etc/apache2/git.passwds
Require valid-user
</LocationMatch>

有人能指出我哪里出错了吗?谢谢

我在 web 服务器中的根目录是 /var/www/kh_webserver 我在 /var/www/kh_webserver/git 中有 git 存储库(例如 test.git)

【问题讨论】:

  • 很抱歉,我没有给您答案,只有一个建议 - 您是否考虑过使用 GitLab 代替?
  • 感谢您的建议。它看起来不错。但我仍然想学习如何设置它(这只是为了学习和个人项目)。我认为这会更直接,就像在 apache 上设置 svn 一样。但是我找到并尝试通过 apache 设置 git 的每个指南都失败了

标签: git apache2.4


【解决方案1】:

我知道这是一篇旧帖子,但您可能想查看我在我的 Wiki 上写的有关如何执行此操作的条目。

http://wiki.flat.cl/index.php?title=Git,_Apache_and_HTTPS_with_a_free_certificate

希望对你有帮助。

【讨论】:

    猜你喜欢
    • 2017-04-16
    • 2014-10-02
    • 2019-07-01
    • 2019-01-09
    • 1970-01-01
    • 2012-03-22
    • 2018-10-02
    • 1970-01-01
    • 2015-04-19
    相关资源
    最近更新 更多