我尝试在我的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:
- apache读取或提供的数据归apache:apache(chown -R)所有
- SElinux(增强安全性的Linux)允许httpd服务读取Z: ls -Z
- 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
发布评论