带有apache2.4 Centos 7的git-http-backend [英] git-http-backend with apache2.4 Centos 7

查看:155
本文介绍了带有apache2.4 Centos 7的git-http-backend的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在我的apache服务器上设置一个Git服务器,但是它不起作用! 我得到以下git.conf

I try to set up a Git-server on my apache server but it dont work! I got the following 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>

我创建了一个用户,但无法访问该网站.

I created a user but I cant acces the site.

Forbidden

You don't have permission to access /git/ on this server.

如果我评论第3行

#ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/

现在,我可以访问该站点并可以看到git存储库.有谁知道我该如何解决. 英语不是我的母语,所以请耐心等待我的文字. 感谢您的问候 山姆

Now I can acces the site and can see the git repository. Does anyone know how I can fix this. English isn't my first language so please be patient with my text. Thanks for reading best regards Sam

推荐答案

跟随 文档:

SetEnv GIT_PROJECT_ROOT /var/www/git

这应该是您拥有git repos的根文件夹(repo1.git,repo2.git等).不应为/git/project1,它看起来像是回购本身的名称.

This should be the root folder under which you have git repos (repo1.git, repo2.git, ...). It should not be /git/project1, which looks like the name of a repo itself.

因此,请尝试以下示例:

So try the example:

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>

注意:在进行交互式会话后,事实证明您需要确保:

Note: after an interactive session, it turns out you need to be sure that:

  • the data read or served by apache are owned by apache:apache (chown -R)
  • SElinux (Security-Enhanced Linux) allows the httpd service to read Z: ls -Z

如果稍后不包括httd_rw,则需要输入(如"为什么我的Apache只能访问根拥有的文件?),以更改其上下文:

If the later point does not include httd_rw, you need to type (as in "How come my Apache can only access root owned files?"), to change its context:

chcon -vR --type=httpd_sys_content_t /html/

这篇关于带有apache2.4 Centos 7的git-http-backend的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆