在Windows上设置的Git服务器使用Git-HTTP-backend.exe [英] Setting up Git Server on Windows With git-http-backend.exe
问题描述
我在使用Apache和git-HTTP-backend.exe一个WS 2008计算机上设置一个Git服务器(1.7.2.3)的过程。我一直在关注一个良好的啧啧<一个href=\"http://www.jeremyskinner.co.uk/2010/07/31/hosting-a-git-server-under-apache-on-windows/\">here.我有GUI的工作,我可以annoymously克隆,如果我把一个回购协议,我可以annoymously推的配置如下:
I am in the process of setting up a Git server (1.7.2.3) on a WS 2008 machine using Apache and git-http-backend.exe. I have been following a good tut here. I have the GUI working, I can annoymously clone and if I put the following in the config of a repo I can annoymously push:
[http]
receivepack = true
我已经添加了以下到httpd.conf文件:
I have added the following to the httpd.conf file:
SetEnv GIT_PROJECT_ROOT C:/GIT/Repositories
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAliasMatch \
"(?x)^/(.*/(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))$" \
"C:/Program Files (x86)/git/libexec/git-core/git-http-backend.exe/$1"
<Directory />
Allow from all
</Directory>
<LocationMatch "^/git/.*/git-receive-pack$">
AuthType Basic
AuthName "Git Access"
AuthUserFile C:/GIT/ApacheConfig/users
AuthGroupFile C:/GIT/ApacheConfig/groups
Require group repogeneral
</LocationMatch>
当我添加LocationMatch我仍然可以克隆annoymously或通过在URL,克隆的git HTTP指定名称:// @乔恩MYSERVER。 COM
When I add the "LocationMatch" I can still clone annoymously or by specifying a name in the URL, git clone http://jon@myserver.com
它会提示输入密码,并克隆。
It will prompt for a password and clone.
但是当我尝试推回回购我得到以下几点:
but when I try to push back to the repo I get the following:
错误:无法访问的网址 HTTP://jon@myserver.com/newtestrepo.git/ ,回报code 22
致命的:混帐-HTTP-推失败。
error: Cannot access URL http://jon@myserver.com/newtestrepo.git/, return code 22 fatal: git-http-push failed
我一直在寻找的 HTTP-backend.exe手册页了解例子,但不能让他们的工作。
I have been looking at the http-backend.exe man page for examples but can not get them to work.
这是我的组文件,(这只是测试了例子,让没有什么会在督促使用):
here is my groups file, (this is just testing out examples so nothing that would be used in prod):
admin: jon steve admin
webview: jon steve web
repogeneral: jon steve
testrepo: jon admin
testrepo2: jon steve web
下面是用户文件:
here is the users file:
jon:$apr1$kEKVExYx$guIF9oYV8buGhFLZr16XN0
steve:$apr1$jvgjF9nv$PvWsHH.cSOBN5ymk6NT1B0
admin:$apr1$vzXgDskN$oszCei3tkHNUgtLj2HkHF/
web:$apr1$wS0do7hb$VA9tsc9c9LwY5PcjfhdwK0
我知道用户名乔恩的工作原理,如果我穿上了GUI部分我可以用用户名乔恩没有问题登录目录的要求,(作为处理locationmatch做同样的用户和组的文件分)。
I know the username jon works as if I put the directory requirement on the gui section I can login with the username jon no problem, (points at the same user and group files as the locationmatch does).
我不知道我在这一点上错过了什么样的配置,(假设它的配置问题)。
I am not sure what configuration I have missed off at this point, (assuming its a configuration issue).
在得到在这个最后一关任何意见将是梦幻般的。
Any advice on getting over this last hurdle would be fantastic.
修改
我一直在玩一些更多,这里是我的信息有:
I have been playing some more and here is the information I have:
如果我克隆一个与回购:
if I clone a repo with:
git clone http://jon@myserver.com/remotetest.git
我可以得到的资料库,但是当我试图推回来:
I can get the repository out, but when I try and push back with:
混帐推主产地
我得到问我密码,我输入它,然后它再要求它,然后我得到了以下错误:
I get asked for my password, I enter it, then it asks for it again, then I get the following error:
C:\\ TEMP \\ remotetest \\ remotetest>混帐推主产地
密码:
密码:
错误:无法访问的网址 HTTP://jon@myserver.com/remotetest.git/ ,回报code 22
致命的:混帐-HTTP-推失败。
C:\temp\remotetest\remotetest>git push origin master Password: Password: error: Cannot access URL http://jon@myserver.com/remotetest.git/, return code 22 fatal: git-http-push failed
在我的Apache的access.log我得到以下几点:
In my Apache access.log I get the following:
192.168.1.2 - - [29/Sep/2010:21:58:19 +0100] "GET /remotetest.git/info/refs?service=git-upload-pack HTTP/1.1" 200 38
192.168.1.2 - - [29/Sep/2010:21:58:51 +0100] "GET /remotetest.git/info/refs?service=git-receive-pack HTTP/1.1" 403 -
192.168.1.2 - - [29/Sep/2010:21:58:51 +0100] "GET /remotetest.git/info/refs HTTP/1.1" 200 -
192.168.1.2 - - [29/Sep/2010:21:58:51 +0100] "GET /remotetest.git/HEAD HTTP/1.1" 200 23
有趣的是,当我在不要紧,我把什么密码,它仍然会工作的URL的用户名克隆。我假设这是因为我应该能够匿名拉。不知道为什么它在这一点上要求输入密码的。
Interestingly when I clone with the username in the URL it doesn't matter what password I put in, it will still work. I am assuming this is because I should be able to pull anonymously. Not sure why it asks for a password at all at that point.
我也看到这个日志错误:
I also see this in the logs error:
[Wed Sep 29 22:33:00 2010] [error] [client 192.168.1.2] client denied by server configuration: C:/Program Files (x86)/Git/libexec/git-core/git-http-backend.exe
[Wed Sep 29 22:33:00 2010] [error] [client 192.168.1.2] client denied by server configuration: C:/Program Files (x86)/Git/libexec/git-core/git-http-backend.exe
编辑2
我试图做重新创建密码文件:
I tried recreating the password file by doing:
htpasswd -c -m C:/git/apacheconfig/users jon
但这并没有帮助。
but this didn't help.
编辑3
在httpd.conf的PHP配置它使用相同的用户文件的基本身份验证:
the PHP config in httpd.conf where it uses the same users file for basic auth:
<Directory "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs">
AuthName "GitUsers"
AuthType Basic
AuthUserFile C:/GIT/ApacheConfig/users
AuthGroupFile C:/GIT/ApacheConfig/groups
require group webview
</Directory>
修改4
OK,所以我可以克隆和annoymous模式愉快推搡,但对于推送身份验证失败。
OK so I can get to cloning and pushing in annoymous mode happily, but authentication fails for the push.
C:\temp\test2\temp\test>git push origin master
Password:
Password:
error: Cannot access URL http://jon@192.168.10.97:8000/repositories/test.git/, return code 22
fatal: git-http-push failed
我改为使用以下httpd.conf中:
I changed the httpd.conf to use the following:
<VirtualHost *:80>
SetEnv GIT_PROJECT_ROOT "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/repositories"
SetEnv GIT_HTTP_EXPORT_ALL
<Directory "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/repositories">
Options Indexes FollowSymLinks MultiViews Includes ExecCGI
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<LocationMatch "^/repositories/.*/git-receive-pack$">
AuthType Basic
AuthName "Git Access"
AuthUserFile "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/repositories/.htpasswd"
Require valid-user
</LocationMatch>
ScriptAliasMatch \
"(?x)^/repositories/(.*/(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))$" \
"C:/Program Files (x86)/Git/libexec/git-core/git-http-backend/$1"
ErrorLog C:/GIT/error_log
CustomLog C:/GIT/access_log combined
</VirtualHost>
有趣的是,当我创建了一个新的回购协议(git的初始化--bare newrepo.git),它没有建立一个信息/文件裁判。我不得不这样做的混帐更新服务器-info命令来创建。
Interestingly, when I created a new repo (git init --bare newrepo.git) It didn't create a info/refs file. I had to do the "git update-server-info" command to create that.
Apache的访问日志有一些有趣的事情,可能是一个线索:
The Apache Access logs have something interesting that could be a clue:
192.168.10.97 - - [05/Oct/2010:22:48:26 +0100] "GET /repositories/test.git/info/refs?service=git-receive-pack HTTP/1.1" 200 -
192.168.10.97 - - [05/Oct/2010:22:48:26 +0100] "GET /repositories/test.git/HEAD HTTP/1.1" 200 23
192.168.10.97 - - [05/Oct/2010:22:48:28 +0100] "PROPFIND /repositories/test.git/ HTTP/1.1" 405 248
这是当我试图推回回购,但他们是GET命令和POST没有。不知道什么是PROPFIND,未发现很多信息上呢。我认为,(读左右),可能有某种重写的事情,即改变POST到GET和杀害,或者什么的。我走出我的深度在这一点上,虽然
That is when I was trying to "push" back to the repo, but they are GET commands and no POST. not sure what the PROPFIND is, not found much info on that yet. I think, (reading around), there might be some sort of rewrite going on, that is changing the POST to a GET and killing it, or something. I am out of my depth at this point though.
感谢
推荐答案
好了,地狱已冻结了,我终于得到这个工作!
OK, so hell has frozen over and I have finally got this working!
我认为有迹象表明,是根本性的错误我的设置两件事情。
I believe there were two things that were fundamentally wrong with my setup.
1)用户没有得到认证穿过,我发现这个帮助:
1) The user was not getting authentication passed through, I found this helped:
SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER
其次我不能让身体目录工作。
Secondly I couldn't get the physical "Directory" to work.
<Directory "C:/GIT/Apache/repositories">
Options +ExecCGI
AuthType Basic
AuthName intranet
AuthUserFile "C:/GIT/Apache/config/users"
Require valid-user
</Directory>
要解决这个我用locationMatch的推拉两者。这意味着您必须验证到推拉。如果你想惹恼拉着你可以删除混帐上传包一节。
To resolve this I used locationMatch for both the pull and push. This means you have to authenticate to pull and push. If you wanted annoy pulling you can remove the "git-upload-pack" section.
希望这可以帮助别人。
下面是我最后的httpd.conf文件:
Here is my final httpd.conf file:
DocumentRoot "C:/GIT/Apache/www"
<Directory />
Options +ExecCGI
Allow from all
</Directory>
<Directory "C:/GIT/Apache/www">
Allow from all
</Directory>
<Directory "C:/GIT/Apache/www/secure">
AuthType Basic
AuthName intranet
AuthUserFile "C:/GIT/Apache/config/users"
require valid-user
</Directory>
SetEnv GIT_PROJECT_ROOT C:/GIT/Apache/repositories
SetEnv GIT_HTTP_EXPORT_ALL
SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER
ScriptAliasMatch \
"(?x)^/(.*/(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))$" \
"C:/Program Files/git/libexec/git-core/git-http-backend.exe/$1"
<LocationMatch "^/.*/git-receive-pack$">
Options +ExecCGI
AuthType Basic
AuthName intranet
AuthUserFile "C:/GIT/Apache/config/users"
Require valid-user
</LocationMatch>
<LocationMatch "^/.*/git-upload-pack$">
Options +ExecCGI
AuthType Basic
AuthName intranet
AuthUserFile "C:/GIT/Apache/config/users"
Require valid-user
</LocationMatch>
这篇关于在Windows上设置的Git服务器使用Git-HTTP-backend.exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!