Home » Forum
  • If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

Win CGI script failing on Apache 2 server

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Win CGI script failing on Apache 2 server

    Hello,

    I've read a couple of posts and the FAQ for CGI scripts, however, whenever Apache is mentioned it is automatically assumed you are on a linux box.

    I'm pointing to an internal web server (Win 2003 Server, SP2) cgi-bin folder where the Zoom application automatically stores the search.cgi application (vs. ftp).

    http://intranet/cgi-bin/search.cgi returns:
    Code:
    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    <html><head>
    <title>500 Internal Server Error</title>
    </head><body>
    <h1>Internal Server Error</h1>
    <p>The server encountered an internal error or
    misconfiguration and was unable to complete
    your request.</p>
    <p>Please contact the server administrator,
     webmaster@domain.tld and inform them of the time the error occurred,
    and anything you might have done that may have
    caused the error.</p>
    <p>More information about this error may be available
    in the server error log.</p>
    <hr>
    <address>Apache/2.2.4 (Win32) Server at intranet Port 80</address>
    </body></html>
    First I'm surprised at the error because the default cgi-bin/printenv.pl works just fine. Second, it seems odd that the html code is posted in the window vs. actually rendering to see only text.

    I've tried to work around this by using the php function passthru() which does open the search box correctly, however, this page is embedded in a CMS (Joomla 1.5RC) and to call this page there are some $_GET[''] variables that are not being captured (intranet/index.php?option=com_zoom&Itemid=64).

    PHP Code:
        $QSTRING $_SERVER['QUERY_STRING'];
        
    putenv('REQUEST_METHOD=GET');
        
    putenv('QUERY_STRING'.$QSTRING);
        
    $command="D:\\wamp\\Apache2\\cgi-bin\\search.cgi";
        
    ob_start();
        
    passthru ($command);
        
    $results ob_get_contents();
        
    ob_end_clean();
        
    //echo JText::_($results);
        
    echo JText::_(ereg_replace("Content-type: text/html;"""$results)); 
    Best results is to figure out how to post the CMS variables within the passthru() function, but if that doesn't work... I need to get cgi-bin/search.cgi displaying correctly so I can create an iframe.

    thanks for the help,

    - MusOX

  • #2
    Error 500 is a very general error generate by web server to indicate some type of failure. But it so general that there are dozens of different issues that can cause it.

    The Zoom CGI is a binary executable CGI. Not a Perl script. So being able to run a Perl script like, printenv.pl doesn't prove much. Many people confuse Perl and CGI, they are not the same thing. CGI is an interface definition, Perl is a programming language.

    So maybe your Apache configuration is trying to execute search.cgi as if it was a Perl script. This would cause an error. Other common CGI problems are covered in the FAQ for CGI issues. Many of the issues in that FAQ cover Windows installations, not just Linux.

    Comment


    • #3
      I'm not sure what part of my httpd config file is incorrect. It seems I have everything in place. In my httpd.conf file:

      Code:
      LoadModule cgi_module modules/mod_cgi.so (without "#" in front)
      
      <IfModule alias_module>
      ScriptAlias /cgi-bin/ "d:/wamp/Apache2/cgi-bin/"
      </IfModule>
      
      <Directory "d:/wamp/apache2/cgi-bin">
      	AllowOverride None
      	#Options None
      	Options +ExecCGI
      	ScriptInterpreterSource registry
      	Addhandler cgi-script .cgi
      	Order allow,deny
      	Allow from all
      </Directory>
      
      <IfModule mime_module>
      AddHandler cgi-script .cgi
      </IfModule>

      Comment


      • #4
        I would still preferr the passthru() function. How can I add the "option=com_zoom&Itemid=64" so the page displays correctly when clicking on "Search"?

        - MusOX

        Comment


        • #5
          It might be the "ScriptInterpreterSource registry" line in your configuration. I am fairly sure that this is not a default Apache setting.

          This directive is used to control how Apache finds the interpreter used to run CGI scripts. The default technique is to use the interpreter pointed to by the #! line in the script. Setting ScriptInterpreterSource registry will cause the Windows Registry to be searched using the script file extension (e.g., .pl) as a search key.

          You might find that .CGI is not defined in the Windows registry. And further find that this ScriptInterpreterSource line is not required?

          I am not familiar with the Joomla product, nor really with the PHP passthru command. So I am not exactly sure where your parameter should be 'added', not what effect it would have if it was added. Are you just trying to add it on to the Zoom query string? We tried to write a FAQ on using Zoom and Joomla but Joomla can be configured in so many ways giving any sensible instructions was hard.

          If your site wasn't an internal private site we could have a closer look at it.

          Comment


          • #6
            Thanks for the reply,

            I dug a little deeper into the cgi faq, and change the script name from .cgi to .exe, reindexed the files and I'm now able to us an iframe. This is my second choice for searching via zoom, but at least I have it working.

            As for the php passsthru command, the joomla values must be first so joomla can generate the page which points to the zoom passthru command.

            Code:
            intranet/index.php?option=com_zoom&Itemid=64&zoom_query=test+search
            &zoom_per_page=10&zoom_cat%5B%5D=-1&zoom_and=1&zoom_sort=0
            Again, thanks for the help!

            - MusOX

            Comment


            • #7
              In your httpd.conf, shouldn't that be:

              Options ExecCGI

              rather than

              Options +ExecCGI

              It worked for me.

              Comment

              Working...
              X