2013-02-27 104 views
3

我剛剛在我的生產服務器上安裝了Git,希望能夠讓GitWeb與它一起工作。我成了得到它,當我遇到顯示如何使用做出混帳網絡工作的教程迷迷糊糊的工作很感興趣......安裝GitWeb - 如何

混帳instaweb -d的WEBrick --start

它的工作原理完全一樣在本教程中介紹在... http://lostechies.com/jasonmeridth/2009/09/27/git-instaweb/

但是在閱讀其他論壇後,好像instaweb並不是真正意義上的使用,而是我應該設置GitWeb以在Apache上運行。

我對Apache很新,所以我不太瞭解我應該做什麼。我一直在按照教程http://unix-heaven.org/node/31。但我不認爲我需要這一切。我想,我需要做的唯一事情就是把我的httpd.conf文件以下...

<VirtualHost *:80> 
    ServerAdmin <a href="mailto:[email protected]">[email protected]</a> 
    ServerName git.example.org 
    ServerAlias git-pub.example.org 
    RedirectMatch ^/$ /gitweb.cgi 
    SetEnv GITWEB_PROJECTROOT /cvs/codeRepository/git 

    Alias /gitweb.js    /srv/www/gitweb/static/gitweb.js 
    Alias /gitweb.css    /srv/www/gitweb/static/gitweb.css 
    Alias /git-logo.png    /srv/www/gitweb/static/git-logo.png 
    Alias /git-favicon.png   /srv/www/gitweb/static/git-favicon.png 

    ScriptAlias/"/srv/www/gitweb/" 

    <Directory "/srv/www/gitweb/"> 
     AllowOverride None 
     Options Indexes FollowSymLinks ExecCGI 
     Order allow,deny 
     Allow from all 
    </Directory> 

    ErrorLog "/var/log/apache2/httpd-git-pub.example.org-access.log" 
    CustomLog "/var/log/apache2/httpd-git-pub.example.org-error.log" common 
</VirtualHost> 

凡/ SRV /網絡/的GitWeb /包含....

$:/srv/www/gitweb # ls -ltr 
total 252 
-rwx------ 1 root root 247917 Feb 27 15:02 gitweb.cgi 
drwx------ 2 root root 4096 Feb 27 15:03 static 

威爾我上面指定的配置工作或我需要指定?如果是的話,我將訪問GitWeb的網址是什麼?我需要serverName,serverAlias和serverAdmin嗎?

感謝您的幫助

+0

缺什麼? – VonC 2013-03-13 10:04:00

回答

2

你會使用的網址會是

http://git.example.org 

但我不太確定你的配置。 Mine is simpler,我總是推薦一個像http(s):// yourServer/gitweb這樣的地址,而不僅僅是http(s):// yourServer /:如果你需要添加更多的服務,你可以添加更多的根url(如/gitweb )。

對於未經驗證即可快速HTTP訪問:

# GitWeb on 80 
Listen 80 
<VirtualHost *:80> 

    ServerName git.example.org 
    ServerAlias git-pub.example.org 

    SetEnv GITWEB_PROJECTROOT /cvs/codeRepository/git 
    SetEnv GIT_HTTP_BACKEND "/usr/local/apps/git/libexec/git-core/git-http-backend" 

    DocumentRoot /srv/www/gitweb 
    Alias /gitweb /srv/www/gitweb 

    <Directory /srv/www/gitweb> 

    Options ExecCGI +FollowSymLinks +SymLinksIfOwnerMatch 
    AllowOverride All 
    order allow,deny 
    Allow from all 

    AddHandler cgi-script cgi 
    DirectoryIndex gitweb.cgi 

    </Directory> 

    BrowserMatch ".*MSIE.*" \ 
    nokeepalive ssl-unclean-shutdown \ 
    downgrade-1.0 force-response-1.0 

    LogLevel Info 
    ErrorLog "/var/log/apache2/gitweb_error_log" 
    TransferLog "/var/log/apache2/gitweb_access_log" 

</VirtualHost> 

注:我original config file(這是一個模板,用佔位符值一樣@[email protected]),我沒有用GITWEB_PROJECTROOT因爲我打電話Gitolite,這知道Git回購站在哪裏。

我做設定在gitweb.conf file一個變量,雖然,這起比GITWEB_PROJECTROOT同樣的作用,根據gitweb documentation

$projectroot:: 
將被預置到項目路徑

絕對文件系統路徑;存儲庫的路徑是$projectroot/$project
安裝期間設置爲$GITWEB_PROJECTROOT
必須爲gitweb正確設置此變量才能找到存儲庫。

例如,如果$projectroot被設置爲 「/srv/git」 通過將以下 中的GitWeb配置文件:

---------------------------------------------------------------------------- 
our $projectroot = "/srv/git"; 
---------------------------------------------------------------------------- 

然後:

------------------------------------------------ 
http://git.example.com/gitweb.cgi?p=foo/bar.git 
------------------------------------------------ 

和它的基於path_info的等價物

------------------------------------------------ 
http://git.example.com/gitweb.cgi/foo/bar.git 
------------------------------------------------ 

將映射到文件系統路徑 '/srv/git/foo/bar.git'。

+0

有些問題... 你爲什麼省略GITWEB_PROJECTROOT?那是因爲它是使用我們的$ projectroot定義在gitweb.cgi中指定的嗎? 並且聽@Port_HTTP_GITWEB @應該只是列表8080吧?我的http端口?或者它是GitWeb專用的端口。 再次感謝 – Richie 2013-02-27 23:58:04

+0

@ user1600419我編輯了我的回答,添加了'GITWEB_PROJECTROOT'並解釋了它爲什麼不在那裏。是的,@ PORT_HTTP_GITWEB @是一個模板文件中的佔位符值,供您根據您選擇的端口進行替換。我編輯了答案以替換(例如)端口80。 – VonC 2013-02-28 06:46:09