我尝试在我的 apache 服务器上设置 Git 服务器,但它不起作用!
我得到了以下 git.conf
SetEnv GIT_PROJECT_ROOT /var/www/html/git/project1
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/
<Directory "/var/www/html/git/project1">
Options ExecCGI Indexes
Require all granted
</Directory>
<LocationMatch "^/git/.*/git-receive-pack$">
AuthType Basic
AuthName "Git Access"
AuthUserFile /var/www/html/git/users/.htpasswd
Require valid-user
</LocationMatch>
我创建了一个用户,但无法访问该网站。
Forbidden
You don't have permission to access /git/ on this server.
如果我评论第3行
#ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/
现在我可以访问该站点并可以看到 git 存储库。有谁知道我该如何解决这个问题。
英语不是我的母语,所以请耐心等待我的文字。
感谢您阅读最诚挚的问候
山姆
下列的git http-backend doc https://git-scm.com/docs/git-http-backend:
SetEnv GIT_PROJECT_ROOT /var/www/git
这应该是 git repos 所在的根文件夹(repo1.git、repo2.git,...)。不应该是/git/project1
,它看起来像存储库本身的名称。
所以尝试一下这个例子:
SetEnv GIT_PROJECT_ROOT /var/www/git
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/
<LocationMatch "^/git/.*/git-receive-pack$">
AuthType Basic
AuthName "Git Access"
Require group committers
...
</LocationMatch>
注意:在交互式会话之后,您需要确保:
- apache 读取或提供的数据归 apache:apache (chown -R) 所有
-
SElinux(安全增强型 Linux) https://en.wikipedia.org/wiki/Security-Enhanced_Linux允许httpd服务读取Z:ls -Z
如果后面的点不包含 httd_rw,则需要输入(如“为什么我的 Apache 只能访问 root 拥有的文件? https://stackoverflow.com/a/16582164/6309"),更改其上下文:
chcon -vR --type=httpd_sys_content_t /html/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)