我安装了gitweb和gitolite。我可以为gitweb访问配置一个repo,它出现在“projects.list”文件中,但是gitweb没有在浏览器中列出repo。
我一直在搜索和搜索,但找不到我想要做的工作。
我的gitweb.conf包含
$git_temp = "/tmp";
# The directories where your projects are. Must not end with a slash.
$projectroot = "/srv/git/repositories";
$projects_list = "/srv/git/projects.list";
我的.gitolite.rc包含
$PROJECTS_LIST = $ENV{HOME} . "/projects.list";
我已经检查过了,并且一旦推回到repo,project.list文件会根据gitlite配置的更改获得更新。所以我认为这只是gitweb没有看到列表并采取行动,但我不知道为什么。
我只是在gitweb页面上找到了“404 - 找不到项目”的项目列表。
更新:
我发现在我的情况下,问题是由不正确的Apache配置引起的。我跟着http://git@boron/testing.git。我的VirtualHost中有以下内容:
# Make sure we can execute gitweb okay
<Directory "/srv/http/gitweb">
Options ExecCGI
AllowOverride None
AddHandler cgi-script .cgi
DirectoryIndex gitweb.cgi
Order allow,deny
Allow from all
</Directory>
这直接执行gitweb.cgi,作为httpd用户,没有任何环境设置。我用对suexec包装器的显式调用替换了这个块:
# Call GitoWeb cgi via suexec wrapper for relevant URLs
ScriptAliasMatch "^/$" /srv/http/git-suexec/gitweb.cgi.suexec-wrapper
这解决了我的问题。
答案 0 :(得分:0)
正如OP在评论中提到的那样,你需要确保Apache配置中的VirtulaHost使用正确的参数/环境变量调用gitweb.cgi:
以下是该服务的httpd.conf
:
请注意它将如何避免ScriptAliasMatch
以及如何设置GIT_HTTP_BACKEND
。
# GitWeb on 8443 # or any port you want
Listen 8443
<VirtualHost hostname>
ServerName hostname
ServerAlias short-hostname
SSLCertificateFile "/path/to/apache/crt"
SSLCertificateKeyFile "/path/to/apache/key"
SSLEngine on
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SetEnv GIT_HTTP_BACKEND /path/to/git/libexec/git-core/git-http-backend
DocumentRoot /path/to/gitweb
Alias /gitweb /path/to/gitweb
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /path/to/gitweb>
SSLOptions +StdEnvVars
Options ExecCGI +FollowSymLinks +SymLinksIfOwnerMatch
AllowOverride All
order allow,deny
Allow from all
AuthName "LDAP authentication for GitWeb repositories"
AuthType Basic
AuthBasicProvider myldap companyldap
AuthzLDAPAuthoritative On
Require valid-user
AddHandler cgi-script cgi
DirectoryIndex gitweb.cgi
RewriteEngine Off
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^[a-zA-Z0-9_\-]+\.git/?(\?.*)?$ /gitweb.cgi%{REQUEST_URI} [L,PT]
</Directory>
</VirtualHost>
原始答案:
这是我的gitweb.conf.pl
:
my $gl_home = $ENV{HOME} = "@H@";
# the following variables are needed by gitolite; please edit before using
# this should normally not be anything else
$ENV{GL_RC} = "$gl_home/.gitolite.rc";
# this can have different values depending on how you installed.
# if you used RPM/DEB or "root" methods it **might** be this:
$ENV{GL_BINDIR} = "/usr/local/bin";
# if you used the "non-root" method it **might** be this:
$ENV{GL_BINDIR} = "$gl_home/gitolite/bin";
# If in doubt take a look at ~/.ssh/authorized_keys; at least one of the lines
# might contain something like:
# command="/home/git/.gitolite/src/gl-auth-command
# and you should use whatever directory the gl-auth-command is in (in this
# example /home/git/.gitolite.src)
# finally the user name
$ENV{GL_USER} = $cgi->remote_user || "gitweb";
# now get gitolite stuff in...
unshift @INC, $ENV{GL_BINDIR};
require gitolite_rc; gitolite_rc -> import;
require gitolite; gitolite -> import;
# set project root etc. absolute paths
$ENV{GL_REPO_BASE_ABS} = ( $REPO_BASE =~ m(^/) ? $REPO_BASE : "$gl_home/$REPO_BASE" );
$projects_list = $projectroot = $ENV{GL_REPO_BASE_ABS};
$export_auth_hook = sub {
my $repo = shift;
# gitweb passes us the full repo path; so we strip the beginning
# and the end, to get the repo name as it is specified in gitolite conf
return unless $repo =~ s/^\Q$projectroot\E\/?(.+)\.git$/$1/;
# check for (at least) "R" permission
my ($perm, $creator) = &repo_rights($repo);
return ($perm =~ /R/);
};
将@ H @替换为您的.gitolite
,.gitoliterc
,repositories
,project.list
文件所在的路径。
注意我是如何定义的$ENV{GL_BINDIR}
:我没有评论第二个定义,因为在我的情况下我做了非root安装,因此:
$ENV{GL_BINDIR} = "$gl_home/gitolite/bin";
确保gitweb_config.perl
包含:
our $home_link_str = "ITSVC projects";
our $site_name = "ITSVC Gitweb";
use lib (".");
require "gitweb.conf.pl";
这就是gitweb
和额外gitweb.conf.pl
之间的联系,它将称为gitolite。