Mil*_*eri 4 apache git centos centos6
我试图在CentOS 6机器上的Apache 2.2上设置git存储库,并安装git。我尝试遵循许多不同的方向,但我很茫然。我目前的情况包括能够clone正常但完全无法推动。
我似乎无法使认证位正常工作,因为我通常可以在设置http.receivepack为的同时执行推送true。
我已经安装AuthzUnixGroup好了mod_authz_external。
我去/var/www/git创建了一个名为repo的仓库my-repo.git,并git init --bare在其中进行了内部。
然后,我将git.conf文件设置/etc/httpd/conf.d/如下:
<VirtualHost "*:80">
SetEnv GIT_HTTP_EXPORT_ALL
SetEnv GIT_PROJECT_ROOT /var/www/git
SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER
ScriptAlias /git /usr/libexec/git-core/git-http-backend
AddExternalAuth pwauth /usr/local/libexec/pwauth
SetExternalAuthMethod pwauth pipe
<Directory "/usr/libexec/git-core/">
AllowOverride None
Options +ExecCGI -Includes
Order allow,deny
Allow from all
</Directory>
<Location "/git">
AuthzUnixGroup on
AuthType Basic
AuthName "Git repository"
AuthBasicProvider external
AuthExternal pwauth
Require group git
</Location>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
指向我的Web浏览器可以mysite/git很好地向我显示HTTP基本登录对话框,该对话框非常有效。我已将自己添加到该组中git,并且在groupsshell上执行a会返回:
naseri sudo git
Run Code Online (Sandbox Code Playgroud)
正如预期的那样。
当我这样做时,git clone http://mysite/git/my-repo.git我从accessdlog文件中的httpd获得以下内容/var/logs/httpd/access_log:
2.177.130.21 - - [11/Jun/2014:18:51:07 +0000] "GET /git/my-repo.git/info/refs?service=git-upload-pack HTTP/1.1" 401 480 "-" "git/1.8.5.2 (Apple Git-48)"
2.177.130.21 - - [11/Jun/2014:18:51:08 +0000] "GET /git/my-repo.git/info/refs?service=git-upload-pack HTTP/1.1" 401 480 "-" "git/1.8.5.2 (Apple Git-48)"
2.177.130.21 - naseri [11/Jun/2014:18:51:08 +0000] "GET /git/my-repo.git/info/refs?service=git-upload-pack HTTP/1.1" 200 256 "-" "git/1.8.5.2 (Apple Git-48)"
2.177.130.21 - naseri [11/Jun/2014:18:51:09 +0000] "POST /git/my-repo.git/git-upload-pack HTTP/1.1" 200 368 "-" "git/1.8.5.2 (Apple Git-48)"
Run Code Online (Sandbox Code Playgroud)
在客户端上,cloneing可以正常工作。我更改了内容,然后尝试通过提交git push内容来推动提交。
这是我在服务器端日志中得到的:
2.177.130.21 - - [11/Jun/2014:18:53:26 +0000] "GET /git/my-repo.git/info/refs?service=git-receive-pack HTTP/1.1" 401 480 "-" "git/1.8.5.2 (Apple Git-48)"
2.177.130.21 - naseri [11/Jun/2014:18:53:27 +0000] "GET /git/my-repo.git/info/refs?service=git-receive-pack HTTP/1.1" 401 480 "-" "git/1.8.5.2 (Apple Git-48)"
2.177.130.21 - naseri [11/Jun/2014:18:53:30 +0000] "GET /git/my-repo.git/info/refs?service=git-receive-pack HTTP/1.1" 403 - "-" "git/1.8.5.2 (Apple Git-48)"
Run Code Online (Sandbox Code Playgroud)
我可以看到我的“需要身份验证”响应是在响应的第一行(401)由Apache发送回去的,但是客户端向我显示了:
fatal: unable to access 'http://mysite/git/my-repo.git/': The requested URL returned error: 403
Run Code Online (Sandbox Code Playgroud)
我对这个问题一无所知,因为将我的浏览器指向相同的URL可以正确地进行身份验证,甚至可以正常工作。
这个老答案
git-http-backend当客户端要求使用git-receive-pack方法时,会返回403 / Forbidden代码。
然后,它回退到WebDAV,但是没有必要使用WebDAV。我有同样的问题; 就我而言,这是由于
REMOTE_USER未设置
由于我的Apache配置中的任何一个=在设置变量时都使用' ',因此请检查它是否更好:
SetEnv REMOTE_USER $REDIRECT_REMOTE_USER
Run Code Online (Sandbox Code Playgroud)
(-两个变量之间没有' ')
还要检查是否也不能(重新)定义REMOTE_USER(因为可能已经定义了,而REDIRECT_REMOTE_USER可能没有定义):请尝试不使用该行。
我永远不必在我的Apache Git配置中定义它。
注意:使用Git 2.21(2019年第一季度,超过5年后),Git应该更强大。
| 归档时间: |
|
| 查看次数: |
891 次 |
| 最近记录: |