Apache 和 git-http-backend
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25995863/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Apache and git-http-backend
提问by MichaelO
I am currently setting up some git repositories on a Ubuntu LTS 14.04 machine with Apache 2.4.7.
我目前正在使用 Apache 2.4.7 的 Ubuntu LTS 14.04 机器上设置一些 git 存储库。
This is the apache config:
这是 apache 配置:
SetEnv GIT_PROJECT_ROOT /var/www/html/git
SetEnv GIT_HTTP_EXPORT_ALL 1
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
<Location /git/oswald.git>
Options +ExecCGI
AuthType Basic
DAV on
AuthName "Git"
AuthUserFile /etc/apache2/git_paragon_passwd
Require valid-user
Order allow,deny
Allow from all
</Location>
The test repository is under /var/www/html/git/oswald.git
. In the repository I have set the config property
测试存储库位于/var/www/html/git/oswald.git
. 在存储库中,我设置了 config 属性
http.receivepack=true
The file git-daemon-export-ok
is present.
该文件git-daemon-export-ok
存在。
If I now try to clone with:
如果我现在尝试克隆:
git clone https://server/git/oswald.git
after authentication I get:
认证后我得到:
fatal: https://server/git/oswald.git/info/refs not valid: is this a git repository?
(git 2.1.0 client, on the server git 1.9.1).
(git 2.1.0 客户端,在服务器 git 1.9.1 上)。
I tried several things, so if I don't use git-http-backend and go via WebDAV I can clone but not push, with git-http-backend I cannot even clone.
我尝试了几件事,所以如果我不使用 git-http-backend 而通过 WebDAV 我可以克隆但不能推送,使用 git-http-backend 我什至无法克隆。
If I change the last line of ScriptAliasMatch
from
如果我改变最后一行ScriptAliasMatch
from
/usr/lib/git-core/git-http-backend
to
到
/usr/lib/git-core/git-http-backend/
as stated in the man page of git-http-backend, I get
如git-http-backend的手册页所述,我得到
fatal: repository 'https://server/git/oswald.git/' not found
with the error.log from Apache:
来自Apache的error.log:
AH00130: File does not exist: /usr/lib/git-core/git-http-backend/oswald.git/info/refs
Does anybody have an idea what is wrong? I have already spent a lot of time going through forums, but no suggestions there did help so far.
有人知道有什么问题吗?我已经花了很多时间浏览论坛,但到目前为止没有任何建议有帮助。
回答by segfault
Is Apache's CGI module enabled? Try running sudo a2enmod cgi
and then restarting Apache.
是否启用了 Apache 的 CGI 模块?尝试运行sudo a2enmod cgi
然后重新启动 Apache。
I had the exact same issue, which ended up being caused by the fact that the CGI module was disabled. In my case, the above command picked and enabled the "cgid" module.
我遇到了完全相同的问题,最终是由于 CGI 模块被禁用造成的。就我而言,上述命令选择并启用了“cgid”模块。
I believe you need the trailing $1
if you're using ScriptAliasMatch
, but should omit the $1
(but keep the trailing slash) if you're using ScriptAlias
.
我相信$1
如果您使用的是尾随ScriptAliasMatch
,但$1
如果您使用ScriptAlias
.
You may also need to add a Directory
block that looks something like this:
您可能还需要添加一个Directory
看起来像这样的块:
<Directory "/usr/lib/git-core">
Options +ExecCgi -MultiViews +SymLinksIfOwnerMatch
AllowOverride none
Order allow,deny
Allow from all
Require all granted
</Directory>
回答by Hank Schultz
For other people running into similar problems with this specific error:
对于遇到此特定错误类似问题的其他人:
fatal: https://server/git/oswald.git/info/refs not valid: is this a git repository?
I eventually found what was causing this issue for me on CentOS 6.5: SELinux. Try running the following command:
我最终在 CentOS 6.5 上找到了导致这个问题的原因:SELinux。尝试运行以下命令:
setenforce 0
If that fixes your issue, then you have a permissions issue with ACLs. Granted, by running the above command, you've turned off a whole host of permissions checks, but it can at least tell you whether this is what's causing your problem. For more information, check out the documentation here.
如果这解决了您的问题,则您的 ACL 存在权限问题。当然,通过运行上述命令,您已经关闭了大量权限检查,但它至少可以告诉您这是否是导致您出现问题的原因。有关更多信息,请查看此处的文档。
Turn the checks back on by running
通过运行重新打开检查
setenforce 1
回答by Jon Wilkes
Add this:
添加这个:
<Directory /usr/lib/git-core>
Require all granted
</Directory>
回答by Marmoy
I don't know if you solved it yet, but take a look at my answer here
我不知道你是否已经解决了,但看看我的答案在这里
I have a couple of ideas:
我有几个想法:
In my experience accessing the repository with https failed, while http worked.
You don't mention changing the repo directory owner to match the apache user, have you done that?
Have you confirmed that the git-http-backend script is located where you expect it to be?
根据我的经验,使用 https 访问存储库失败,而 http 有效。
您没有提到更改 repo 目录所有者以匹配 apache 用户,您这样做了吗?
您是否确认 git-http-backend 脚本位于您期望的位置?