2012-03-19 114 views
1

我安裝了gitweb和gitolite。我可以爲gitweb訪問配置一個倉庫,它出現在「projects.list」文件中,但是倉庫沒有在瀏覽器中被gitweb列出。如何讓gitolite/gitweb一起工作?

我一直在尋找和搜索,但無法找到我失蹤,使這項工作。

我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"; 

我檢查和projects.list文件去獲取即時更新每更改gitlite配置一次這被推回到回購。所以我認爲這只是gitweb沒有看到列表並採取行動,但我不知道爲什麼。

我剛剛得到了「404 - 找不到項目」的項目列表應該在哪裏的gitweb頁面。

UPDATE:

我發現,在我的情況下,問題是由不正確的Apache配置造成的。我跟着http://[email protected]/testing.git。我在我的虛擬主機以下幾點:

# 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

我已編輯我的答案,包括正確的httpd.conf。我相信它比你的完整一點。 – VonC 2012-03-20 12:16:07

回答

0

由於OP提到的評論,你需要確保你的VirtulaHost在Apache的配置要求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} = "@[email protected]"; 

# 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/); 
}; 

通過您的路徑在您.gitolite.gitolitercrepositoriesproject.list文件替換@ H +。

注意我是如何定義$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之間的聯繫。

+0

謝謝你。今天早上我已經解決了我的問題,並且更新了我的問題。我在各種帖子中發現了一些對gitweb.conf.pl的引用,但我似乎沒有這個文件,但是我確實有gitweb.conf。我不知道我是否仍然錯過了一些東西,但我的設置似乎現在可以工作。 – starfry 2012-03-20 12:04:43