4

I've recently set up Apache 2.2 and git on one of our Windows XP PCs for gitweb access using the setup at https://git.wiki.kernel.org/index.php/MSysGit:GitWeb As noted on the wiki, the only version of Perl that seems to work with gitweb the way it is coded is the one included with MSysGit. ActivePerl and StrawberryPerl don't implement a certain required feature so another interpreter is not an option.

C:\Program Files\Git\bin>perl.exe --version
This is perl, v5.8.8 built for msys

In any case, it is set up and it works but for some reason there is an approximately 10 second delay for every page load. To troubleshoot this I made a simple helloworld.cgi and placed it in the directory next to gitweb.cgi. It is set up to use the same perl interpreter as gitweb:

#!C:\Program Files\Git\bin\perl.exe
print "Content-type: text/html\n\n";
print "Hello, world!\n";

This script too takes over 10 seconds to execute on the server. If I fire up a command prompt and execute it directly with the same perl executable, it executes instantly.

mod_cgi is loaded in the Apache config and I'm using the config stanzas shown on the git wiki modified for my system:

# Config to make the gitweb CGI available through Apache.
Alias /git "C:/Program Files/Git/share/gitweb"
<Directory "C:/Program Files/Git/share/gitweb">
  AddHandler cgi-script .cgi
  <Files ~ "\.cgi$">
    Options +ExecCGI
  </Files>
  AllowOverride None
  Order allow,deny
  Allow from all
  DirectoryIndex gitweb.cgi
</Directory>

Are there some other config directives I'm missing? It doesn't seem to matter whether I access it from another PC or via localhost directly on the machine so I think that rules out DNS. It isn't dumping anything into the Apache error log, either.

3 Answers 3

2

I fixed this by using cygwin's version of Perl instead of msysgit. That will really speed up your response time.

To do this, you will need to modify the gitweb.cgi script in 3 places The first line should say this:

#!C:/cygwin/bin/perl

I choose to use cygwin's version of git instead of msysgit's as well, so you need to make sure the projectroot is in cygwin's format:

our $GIT = "C:/cygwin/bin/git";
our $projectroot = "/cygdrive/c/temp/repos";
0

This is because Apache sanitizes environment variables before running cgi processor. The only variables that it leaves intact are:

  • PATH
  • PROMPT
  • SystemRoot
  • COMSPEC
  • PATHEXT
  • WINDIR

It also adds a whole lot of Apache-specific variables (such as SCRIPT_NAME).

So the solution is to use some kind of wrapper (i'm using a Python cgi scrip, using normal W32 Python) that sets some of the variables back before running msys shell or msys perl (the right way of running msys stuff from outside is c:/path/to/sh.exe --login -c "perl /path/to/script.cgi").

The variables that need to be set (in addition to the ones that Apache passes through or sets by itself) are:

  • LOGONSERVER = \\MACHINENAME
  • TMP = C:\Users\USERNAME\AppData\Local\Temp

TMP is not required, but msys will complain if it can't find it.

You can use any directory for TMP, obviously.

I have no idea why LOGONSERVER is needed, sorry.

Make sure that wrapper script/application sets stdout to binary mode, otherwise Apache is going to throw a Premature end of script headers error.

-1

Just add this line in httpd.conf:

SetEnv LOGONSERVER \\\\machine
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .