500 Internal Server Error /cgi-bin/

Zephillis
Zephillis used Ask the Experts™
on
    Hello, Im trying to get my CGI scripts to work properly. Idid all the steps in all the documentation from APache, even O'Reilly (where wasnt anything really) here is part of my httpd.conf:

ScriptAlias /cgi-bin/ /var/www/cgi-bin/

<Directory "/var/www/cgi-bin">
      Options +ExecCGI
     AllowOverride Options
      Allow from from all
        Order allow,deny
</Directory>

#Then under Virtual Host:

ScriptAlias /cgi-bin/ /var/www/cgi-bin/

<Directory "/var/www/cgi-bin">
      Options +ExecCGI
     AllowOverride Options
      Allow from from all
     Order allow,deny
     AddHandler cgi-script cgi pl
</Directory>

#Is there something that I am doing wrong? I also have #the .htaccess setup in the dir with:

AllowOverride Options
Options +ExecCGI

#chmod 0755 my scripts in the cgi-bin

#What is it that I am missing??
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
I forgot to add, that in my error_log it's giving me:
[error] (13)Permission denied: exec of /var/www/cgi-bin/powup.cgi

and

Premature end of script headers  (now I think that was cause I diddnt chmod it at the time)..

Thanks in Advance

Matt

Author

Commented:
Okay I see that AllowOveride Options is not to be in .htaccess. So I removed that, and only
Options +ExecCGI
is left in there, so I goto try it again and nope, the errorlog say:
Can't Open perl script "a square is in here" : No such file or Directory
And then after that a Premature End of course.

Now in the CGI's do I need to remove the # from the front of !/usr/bin/perl  ?


Lol thanks in advance   Again....  :)

Author

Commented:
LOL This is getting old sorry yall for me being a pain in the a**. I removed the # from infront of !/usr/bin/perl in the cgi files

restart APache ofcourse and try again..
Here is the new Error:
[error] (8)Exec format error: exec of /var/www/cgi-bin/uploader.cgi failed

and of course a Premature end

suEXEC causing it?
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

try

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


and keep your cgi files to the /var/www/cgi-bin directory.
Use AddHandler line only if you require the cgi script to run outside the ScriptAliased directories (I don't recommend this)

You require the # actually it should be the first character of the file correct syntax is

#!/usr/bin/perl

is your production machine is also running on Linux (Unix type) machine?

Author

Commented:
Yes it is on Linux, I added the Alias and Dir you supplied to me, and slapped it in. Still no luck.. I added # in front of !/usr/bin/perl and I read my error log and this is was poped up:

[Sun Nov 17 13:26:59 2002] [error] [client 192.168.1.1] Premature end of script headers: /var/www/cgi-bin/uploader.cgi

My favorite error, but thats all I received no other errors from the last attempt. I have tried several other CGI Scripts so I know it's not the scripts (Hopefully)

TIA

Author

Commented:
Okay im still getting the error 13 Permission denied in my error log  exec of ../hello.pl failed...

Commented:
Does the scripts runs if executed from cmd line?  Make sure that the CGI must send a correct HTTP header, otherwise your script would fail.

Btw, please replace the ScriptAlias and Directory with the one supplied by bansidhar. And restart apache.

Author

Commented:
Samri,

As to can it be executed from my command line.. if typing perl powup.cgi and it displays the code, does that constitute as executing? If yes then it works  :) as to my CGI sending the correct HTTP header? I do not know. And exactly where in my httpd.conf do I insert the ScriptAlias and Directory ? In my vhost? or above that?

I have too apologize, I am rather new to using Apache, and Linux even though I have been using it for some time, I am still well below rookie, I discover new things everyday with Linux and I love it.

Thanks in Advance
Matt
Your script should send

Content-type: text/html

as the first line and two newline characters

try putting the following line in the begining of your script after #!/usr/bin/perl

print "Content-type: text/html\n\n"


Is your perl interpreter located in /usr/bin/ directory?
apache looks at the first line and if it sees it starting with #! it passes the script to the interpreter denoted by the rest of the line and return the output of the interpreter to the web client.

In your case the script is passed to perl executable located at /usr/bin

have you uploaded the files from windows or MAC to the server via FTP. If so pleae upload again and this time make sure you are uploadung in ASCII mode. Some ftp clients by default upload the CGI files in Binary mode by default.

Author

Commented:
Yes perl is located there. according to "whereis"

yeah the string is in the cgi's as second line and still no go..

Again I just would like to thank you all for the help, I think that this web-service is a very effective idea, wish I thought of it....... :-)
Try removing the .htaccess

Author

Commented:
No i just downloaded with a win32 machine the files were all in zip format and I xferd via samba to the linux server and then uncomressed it from there.

Author

Commented:
okay removing

Author

Commented:
.htacces removed, apache restarted and still no go  :\
your script seems to have non ASCII characters. I faced this problem once. The win32 and the linux newline characters are not same. This causes the problem I also uploaded the files from a win32 machine and was getting the same problem.

try opening the script in some linux text editors and remove the non ASCII characters the save it. Or try entering the following script in your linux text editor.

#!/usr/bin/perl

print "Content-type: text/html\n\n";
print "<html><body>";
print "<h1>Hello It Works</h1></body></html>";

then save and exit and chmode to 755

try calling the script

OR

unzip one of the scripts and upload it to the /cgi-bin directory by any ftp from win32 machine (If you have one).

BE SURE TO USE TYPE "ASCII"

Author

Commented:
Yessir that was the problem.. I remebr I edited them in Windows, forgot about that damn text editor, thats why it has the lil squares and stuff like that after each line.. thats awesome, and here is the 200 points..

Thanks again
Matt
zephillis2@msn.com
thanks for the points

bansidhar
bansidhar@hotmail.com

Commented:
gee this is the fast solving case

Author

Commented:
lol

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial