Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot get CGI scripts to run...

Status
Not open for further replies.

Chewie71

MIS
Sep 4, 2001
89
US
I just installed OpenBSD 3.2 and am running the default install of Apache(1.3.26) on the server. When I try to access the test-cgi script, or any other script for that matter, in my cgi-bin directory I get a "500 Internal Server Error."

I can run the test-cgi script at the shell prompt and it returns the information just fine. At this point I have not touched the httpd.conf file except to look in it to make sure the CGI stuff is configured...which as far as I can tell it is.

ScriptAlias /cgi-bin/ "/var/
<Directory &quot;/var/ AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>

Maybe I have permissions set wrong? I'm pretty much of an Apache newb so any help is appreciated.

Thanks,
Matt
 
I think you need to set set

Options ExecCGI

for this directory...

(don't forget to chmod the CGI file!! ;-))

hope that helped [pipe]
 
Thanks Salty...here's what I did.

I changed the Options None line to Options ExecCGI in httpd.conf.

The test-cgi script is chmod'd 777, it is also chowned to the and group...which is what Apache runs as on OpenBSD3.2.

I stopped and restarted Apache and am still getting the 500 error from the browser
Now what? :)

Thanks for your help.

Matt
 
Apache have some excellent documentation on how to get CGI scripts running on your machine. i know it's a cop out on my part, but this is where i learned how to set up CGI on my server (it was with the same version of apache at the time as well!!)


it's very thorough, even if i cannot spell that word!! ;-)

hope that put your problem to bed
TheSaltyDuke [pipe]
 
Hi guys,

Cian

777 gives more permissions than 755, therefor the change should be more restrictive and should not help the script to run. BTW, great to see you posting in this forum. [wink]

SaltyDuke

You don't need to add an exec attribute for a ScriptAlias directive, that is enabled by default.

Chewie71

Check that the path to perl is correct.

Check that your script outputs the correct header.

As Cian mentioned, check that you have the extension mapped to perl, this is done with the following line:

AddHandler cgi-script .cgi .pl

If you only have .cgi then add .pl to the end of the line so that it looks like the above.

Hope this helps Wullie

sales@freshlookdesign.co.uk

The pessimist complains about the wind. The optimist expects it to change. The leader adjusts the sails. - John Maxwell
 
From the CGI docs I understood that I didn't need the AddHandler line if I use ScriptAlias. Apache will assume that everything in the ScriptAlias directory is a script to be executed....whether it has a .cgi or .pl extension or not. Am I wrong about that?

Matt
 
I don't think that's correct. I believe you still need to make the file association with the AddHandler command. Can't hurt, anyway. Newposter
&quot;Good judgment comes from experience. Experience comes from bad judgment.&quot;
 
Chewie71 is correct. Everything in a ScriptAlias'd directory will be executed by Apache. //Daniel
 
danielhozac

Ok then :) So why ain't they executing?

httpd_access log

192.168.1.1 - - [06/Nov/2002:11:54:23 -0600] &quot;GET /cgi-bin/test.cgi HTTP/1.1&quot; 500 611

error_log

[Wed Nov 6 11:54:23 2002] [error] (2)No such file or directory: exec of /cgi-bin/test.cgi failed
[Wed Nov 6 11:54:23 2002] [error] [client 192.168.1.1] Premature end of script headers: /cgi-bin/test.cgi
 
Here's the ScriptAlias section of my httpd.conf

ScriptAlias /cgi-bin/ &quot;/var/
#
# &quot;/var/ should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory &quot;/var/ AllowOverride None
Options +ExecCGI
Order allow,deny
Allow from all
</Directory>
 
If you run [tt]/usr/bin/perl /var/www/cgi-bin/test.cgi[/tt], do you get the expected results? //Daniel
 
RESOLVED!!!!!

I got on the OpenBSD 'www' mailing list and asked the same question. Got my answer.

By default on OpenBSD 3.2 Apache is running chrooted to /var/ so is not allowed to execute anything outside that directory...even though it is set in the httpd.conf file. Probably if I'd read the httpd(1) man page or the OpenBSD 3.2 changelog I might have figured that out.

Who reads the documentation though...trial and error...mostly error...is my motto. :)

Thanks everyone for all the suggestions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top