Problems running CGI-scripts in Apache.

Claruz

Dogcow
I am having some problems with my built in Apache installation. I am running Mac OS X Client, not server, version 10.2. Here is the output from httpd -version:

Server version: Apache/1.3.26 (Darwin)
Server built: 07/27/02 14:29:15

I am trying to run cgi-scripts. I found the main "cgi-bin" folder to be /Library/WebServer/CGI-Executables. So that is where the cgi scripts are being run from. I keep getting "500 Internal Server Error". I have made sure that the permission is correct for the script. I also checked the #!/usr/bin/perl header of the script, and it appears to be correct. I have read all that I can find in the Apache manual about this and I can't see what I am doing wrong. Here is what the error log says about it :

[Fri Mar 21 12:54:37 2003] [error] (2)No such file or directory: exec of /Library/WebServer/CGI-Executables/perl_test.cgi failed
[Fri Mar 21 12:54:37 2003] [error] [client 127.0.0.1] Premature end of script headers: /Library/WebServer/CGI-Executables/perl_test.cgi

Running the script from the terminal work fine, even when I use "sudo -u www perl <script>" to try and emulate the permissions that the script would have when being run from the webserver. The script I am trying to run is part of the ikonboard 3.11 installation and is designed to test your webserver to see if everything will run fine. The script should be fine, all it does is check the Perl version, CGI version, sendmail path and some other simple stuff. I can post the script here if you want. Is there any other setup I need to do to run CGI scripts? If not, then what could be wrong?

Thanks for any help you can give.
 
Small thing - does the script have the executable bit set? Probably does, but if it doesn't, this is the sort of thing that happens, so I thought I'd ask.
 
If you mean the permission for executable, then yes, it is set. The script has been chmod 755 so it is executable and readable by everyone, and writable by the owner. If it wasn't the permission thing you meant then please explain what, I might have missed it.

Thanks
 
You could use localhost rather than 127.0.0.1 and it would work as well. And yes, the permission for execution was what I was talking about.
 
Are you sure the sh'bang is right (#!/usr/bin/perl)?

Did you remember to print "Content-Type: text/html\n\n"; before outputing anything else?

Have you changed httpd.conf? Does it still include these lines without a # in front of them:
Code:
AddHandler cgi-script .cgi
.
.
.
ScriptAlias /cgi-bin/ "/Library/WebServer/CGI-Executables/"

What does the script do when you run it from the command line:
bash-2.05a$ perl /Library/WebServer/CGI-Executables/test.cgi
Content-Type: text/html

Here's an example of a .cgi that proves that .cgi's work on your website!

The name of this .cgi is test.cgi and its located in your public_html directory
.
.
.
 
As I said earlier the #!/usr/bin/perl is correct, and the script runs fine from the terminal. The script does print the headers before anything else, I didn't write it. The http.conf file is fine, I just checked it. Don't worry....unless I decide to use CGI again at some point you won't hear from me :)

Thanks
 
Back
Top