我在我的服务器上运行 gitweb 和 gitolite:http://git.jshawl.com/ http://git.jshawl.com/
我在设置时遇到问题git-http-backend
允许匿名克隆。
这是我的虚拟主机文件(/etc/apache2/extra/httpd-vhosts.conf
) 好像:
<VirtualHost *:80>
DocumentRoot "/Users/git/repositories"
ServerName git.jshawl.com
<Directory "/Users/git/repositories">
Options ExecCGI +FollowSymLinks +SymLinksIfOwnerMatch
AllowOverride All
order allow,deny
Allow from all
AddHandler cgi-script cgi
DirectoryIndex gitweb.cgi
</Directory>
<LocationMatch "^/.*/git-receive-pack$">
AuthType Basic
AuthName "Git Access"
Require group committers
</LocationMatch
SetEnv GIT_PROJECT_ROOT /Users/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))$" \
/usr/libexec/git-core/git-http-backend/$1
ScriptAlias / /Users/git/repositories/gitweb.cgi/
`
我按照这里的指示进行操作:http://www.kernel.org/pub/software/scm/git/docs/git-http-backend.html http://www.kernel.org/pub/software/scm/git/docs/git-http-backend.html,但我一直遇到 502 错误。
我的阿帕奇错误日志显示:[Fri Aug 24 19:29:32 2012] [error] [client 198.228.200.148] client denied by server configuration: /usr/libexec/git-core/git-http-backend
另外,添加所有这些已经取消了我的 gitweb 安装(以前位于http://git.jshawl.com http://git.jshawl.com)
我究竟做错了什么?
Here is 这方面的另一种方法httpd.conf https://github.com/VonC/compileEverything/blob/master/apache/env.conf.tpl#L49-84这对于克隆/推/拉效果很好,但是它不调用 gitweb.cgi:
GitWeb 是用来浏览的,不是用来克隆的
(小摘录,删除身份验证详细信息和 SSL 详细信息)
# GitHttp on @PORT_HTTP_HGIT@
Listen @PORT_HTTP_HGIT@
<VirtualHost @FQN@:@PORT_HTTP_HGIT@>
ServerName @FQN@
ServerAlias @HOSTNAME@
SetEnv GIT_PROJECT_ROOT @H@/repositories
SetEnv GIT_HTTP_EXPORT_ALL
SetEnv GITOLITE_HTTP_HOME @H@
ScriptAlias /hgit/ @H@/gitolite/bin/gitolite-shell/
SetEnv GIT_HTTP_BACKEND "@H@/usr/local/apps/git/libexec/git-core/git-http-backend"
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Location /hgit>
AddHandler cgi-script cgi
</Location>
</VirtualHost>
换句话说:
-
git-http-backend
被变量引用GIT_HTTP_BACKEND
, but 如果您使用 Gitolite V3,则不需要它.
-
gitolite-shell https://github.com/sitaramc/gitolite/blob/master/src/gitolite-shell当你使用时被调用
/hgit/
在您的克隆地址中:theat GitoliteV3 脚本将检查您是否有权克隆该存储库,如果有,将调用脚本后面的命令git-http-backend
: 'git-receive-pack
'(用于推送)或 'git-upload-pack
'(用于克隆/拉取/获取),直接来自 git 源本身http-backend.c https://github.com/git/git/blob/master/http-backend.c#L518-533.
So:
git clone https://yourServer/hgit/yourRepo
将调用 gitolite,它将调用 'git-receive-pack
' or 'git-upload-pack
'.
它首先会通过调用来分析http请求sub http_simulate_ssh_connection() https://github.com/sitaramc/gitolite/blob/master/src/gitolite-shell#L200-L221
sub http_simulate_ssh_connection {
# these patterns indicate normal git usage; see "services[]" in
# http-backend.c for how I got that. Also note that "info" is overloaded;
# git uses "info/refs...", while gitolite uses "info" or "info?...". So
# there's a "/" after info in the list below
if ( $ENV{PATH_INFO} =~ m(^/(.*)/(HEAD$|info/refs$|objects/|git-(?:upload|receive)-pack$)) ) {
my $repo = $1;
my $verb = ( $ENV{REQUEST_URI} =~ /git-receive-pack/ ) ? 'git-receive-pack' : 'git-upload-pack';
$ENV{SSH_ORIGINAL_COMMAND} = "$verb '$repo'";
} else {
# this is one of our custom commands; could be anything really,
# because of the adc feature
my ($verb) = ( $ENV{PATH_INFO} =~ m(^/(\S+)) );
my $args = $ENV{QUERY_STRING};
$args =~ s/\+/ /g;
$args =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
$ENV{SSH_ORIGINAL_COMMAND} = $verb;
$ENV{SSH_ORIGINAL_COMMAND} .= " $args" if $args;
http_print_headers(); # in preparation for the eventual output!
}
$ENV{SSH_CONNECTION} = "$ENV{REMOTE_ADDR} $ENV{REMOTE_PORT} $ENV{SERVER_ADDR} $ENV{SERVER_PORT}";
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)