Results 1 to 16 of 16

Hybrid View

  1. #1
    Join Date
    Mar 2004
    Location
    Florida
    Posts
    28

    Exclamation Apache2 + CGI help request

    Hey all...
    After some delays and alot of work, I've finally gotten my webserver back up and running. I've ironed out all the bugs except one. i'm trying to run a CGI script for a hit counter, but everytime I access the CGI, I get the following error:

    <!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,
    XXXXXXXX@XXXX.com 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>
    </body></html>

    I'm running RH FC3, with Apache 2.5. I've verified that the module is being loaded in the server, and in the config, Ive set the following paramters:

    ScriptAlias /cgi-bin/ "/usr/local/apache2/cgi-bin/"

    <Directory "/usr/local/apache2/cgi-bin">
    AllowOverride None
    Options +ExecCGI
    Order allow,deny
    Allow from all
    </Directory>

    AddHandler cgi-script .cgi .pl

    Compiled in modules:
    core.c

    mod_cgi.c

    (There are other modules, but I didn't think they were necessary to list)

    Ok.. so if i'm reading this right, I think I've gotten everything right... What am I missing?

  2. #2
    Join Date
    Feb 2003
    Location
    Canada
    Posts
    1,010
    1) Check the Apache error log for that virtualhost

    2) Check to make sure your cgi script is executable, the shebang line at the top of the script is correct, etc etc etc.

    The log file should be the first place you check for problems. Looks to me like the script exited with an error.

  3. #3
    Join Date
    Mar 2004
    Location
    Florida
    Posts
    28
    That actually isn't a virtual host. it's a dedicated host on the server...

    Here's what's in the log...

    (8)Exec format error: exec of '/usr/local/apache2/cgi-bin/counter/setup.cgi' failed
    Premature end of script headers: setup.cgi
    File does not exist: /var/www/html/favicon.ico
    (13)Permission denied: exec of '/usr/local/apache2/cgi-bin/test-cgi' failed
    Premature end of script headers: test-cgi
    (13)Permission denied: exec of '/usr/local/apache2/cgi-bin/test-cgi' failed
    Premature end of script headers: test-cgi
    (13)Permission denied: exec of '/usr/local/apache2/cgi-bin/printenv' failed
    Premature end of script headers: printenv


    I went in and tried setting the CGI scripts to 777 permissions... no go.


  4. #4
    Join Date
    Feb 2003
    Location
    Canada
    Posts
    1,010
    I meant the virtualhost from Apache

    Try running setup.cgi from a shell and see what it outputs.

    Should see something like Content-Type: text/html\r\n etc

  5. #5
    Join Date
    Mar 2004
    Location
    Florida
    Posts
    28
    Ok.. forgive me for being a noob.. how do I run that CGI from shell? /usr/local/apache2/cgi-bin/<cgiscript> ?

  6. #6
    Join Date
    Feb 2003
    Location
    Canada
    Posts
    1,010
    That should do it.

  7. #7
    Join Date
    Mar 2004
    Location
    Florida
    Posts
    28
    If it's supposed to come back immediately with a response... it's not. After kicking that off, the ccursor drops down, and just sits. No more entries in the error log as a result of me trying this.

  8. #8
    Join Date
    Feb 2003
    Location
    Canada
    Posts
    1,010
    Probably part of your problem.

    What are the top 5 lines of the script.

  9. #9
    Join Date
    Mar 2004
    Location
    Florida
    Posts
    28
    /usr/bin/perl -w
    print "Content-type: text/html\n\n";

    print qq~<html>
    <head>
    <style type="text/css">
    <!--
    a:link {text-decoration:none}
    a:visited {text-decoration:none}
    a:hover {text-decoration:underline}

  10. #10
    Join Date
    Feb 2003
    Location
    Canada
    Posts
    1,010
    Looks correct.

    Can you chmod 755 the test-cgi binary file and try that? To confirm your cgi's are being executed.

    If that works, definitely an error in your counter script *somewhere*.

  11. #11
    Join Date
    Mar 2004
    Location
    Florida
    Posts
    28
    lo and behold the results of such endeavor... :

    Content-type: text/plain; charset=iso-8859-1

    CGI/1.0 test script report:

    argc is 0. argv is .

    SERVER_SOFTWARE =
    SERVER_NAME =
    GATEWAY_INTERFACE =
    SERVER_PROTOCOL =
    SERVER_PORT =
    REQUEST_METHOD =
    HTTP_ACCEPT =
    PATH_INFO =
    PATH_TRANSLATED =
    SCRIPT_NAME =
    QUERY_STRING =
    REMOTE_HOST =
    REMOTE_ADDR =
    REMOTE_USER =
    AUTH_TYPE =
    CONTENT_TYPE =
    CONTENT_LENGTH =

  12. #12
    Join Date
    Feb 2003
    Location
    Canada
    Posts
    1,010
    Looks like you ran it from the command line?

    Can you access it from a browser?

  13. #13
    Join Date
    Mar 2004
    Location
    Florida
    Posts
    28
    This is what i got when accessing it from a browser:

    CGI/1.0 test script report:

    argc is 0. argv is .

    SERVER_SOFTWARE = Apache/2.2.3 (Unix) PHP/5.1.4
    SERVER_NAME = www.monkeysmorgue.com
    GATEWAY_INTERFACE = CGI/1.1
    SERVER_PROTOCOL = HTTP/1.1
    SERVER_PORT = 80
    REQUEST_METHOD = GET
    HTTP_ACCEPT = text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
    PATH_INFO =
    PATH_TRANSLATED =
    SCRIPT_NAME = /cgi-bin/test-cgi
    QUERY_STRING =
    REMOTE_HOST =
    REMOTE_ADDR = X.X.X.X
    REMOTE_USER =
    AUTH_TYPE =
    CONTENT_TYPE =
    CONTENT_LENGTH =

  14. #14
    Join Date
    Mar 2004
    Location
    Florida
    Posts
    28
    FOUND IT!!!! Adam - Thanks a ton!! As usual, I learn something new everyday!!

  15. #15
    Join Date
    Feb 2003
    Location
    Canada
    Posts
    1,010
    That's great.

  16. #16
    Join Date
    Mar 2004
    Location
    Florida
    Posts
    28
    Yes Thanks A TON!! Keep warm up there.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •