Results 1 to 16 of 16
Thread: Apache2 + CGI help request
-
10-29-2006, 01:14 AM #1Newbie
- Join Date
- Mar 2004
- Location
- Florida
- Posts
- 28
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?
-
10-29-2006, 01:21 AM #2Web Hosting Master
- 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.
-
10-29-2006, 01:49 AM #3Newbie
- 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.
-
10-29-2006, 01:52 AM #4Web Hosting Master
- 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
-
10-29-2006, 02:02 AM #5Newbie
- 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> ?
-
10-29-2006, 02:04 AM #6Web Hosting Master
- Join Date
- Feb 2003
- Location
- Canada
- Posts
- 1,010
That should do it.
-
10-29-2006, 02:16 AM #7Newbie
- 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.
-
10-29-2006, 02:17 AM #8Web Hosting Master
- Join Date
- Feb 2003
- Location
- Canada
- Posts
- 1,010
Probably part of your problem.
What are the top 5 lines of the script.
-
10-29-2006, 02:21 AM #9Newbie
- 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-29-2006, 02:29 AM #10Web Hosting Master
- 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*.
-
10-29-2006, 02:42 AM #11Newbie
- 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 =
-
10-29-2006, 02:44 AM #12Web Hosting Master
- 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?
-
10-29-2006, 02:47 AM #13Newbie
- 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 =
-
10-29-2006, 02:50 AM #14Newbie
- Join Date
- Mar 2004
- Location
- Florida
- Posts
- 28
FOUND IT!!!! Adam - Thanks a ton!! As usual, I learn something new everyday!!
-
10-29-2006, 02:50 AM #15Web Hosting Master
- Join Date
- Feb 2003
- Location
- Canada
- Posts
- 1,010
That's great.
-
10-29-2006, 02:51 AM #16Newbie
- Join Date
- Mar 2004
- Location
- Florida
- Posts
- 28
Yes Thanks A TON!! Keep warm up there.