安装GitWeb -如何



我刚刚在我的生产服务器上安装了Git,我希望能让GitWeb与它一起工作。当我偶然发现一个教程展示如何使用…

使git web工作时,我变得非常感兴趣。

git 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:admin@example.org">admin@example.org</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/www/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

配置我上面指定的工作还是我需要指定?如果是这样,我该从哪个url访问giweb ?我需要serverName, serverAlias和serverAdmin吗?

谢谢你的帮助

您将使用的url为

http://git.example.org

但是我不太确定你的配置。我的更简单,我总是建议一个地址像http(s)://yourServer/giitweb,而不是仅仅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>

注意:在我的原始配置文件(这是一个模板,与占位符值像@PORT_HTTP_GITWEB@),我没有使用GITWEB_PROJECTROOT,因为我调用Gitolite,它知道Git的仓库在哪里。

我确实在gitweb.conf文件中设置了一个变量,但是,根据giitweb文档,它起着与GITWEB_PROJECTROOT相同的作用:

 $projectroot::

文件系统的绝对路径,它将被附加到项目路径;存储库的路径是$projectroot/$project
安装时设置为$GITWEB_PROJECTROOT
这个变量必须被正确设置,这样giitweb才能找到存储库。

例如,将$projectroot设置为"/srv/git",输入如下在giitweb配置文件中:

----------------------------------------------------------------------------
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。


2018年8月更新,适用于Git 2.19(五年后的2018年第三季度)

" git instaweb "已被调整,以便在基于RedHat的发行版上更好地运行新的Apache。

参见Sebastian Kisela (skisela)的commit 757b124 (07 Aug 2018)和commit 1976311 (08 Aug 2018)。
(由juno C Hamano—gitster—在commit 93ded33, 2018年8月20日合并)

git-instaweb: fix apache2 config with apache>= 2.4

生成的apache2配置在apache>= 2.4时失败。错误日志州:

AH00136: Server MUST relinquish startup privileges before accepting connections.  
Please ensure mod_unixd or other system security module is loaded.
AH00016: Configuration Failed

通过加载unixd模块修复此问题。
这也适用于旧的httpd,所以不需要IfVersion条件。(在CentOS-6上使用httpd-2.2.15测试)

最新更新