Link to home
Start Free TrialLog in
Avatar of Zephillis
Zephillis

asked on

500 Internal Server Error /cgi-bin/

    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??
Avatar of Zephillis
Zephillis

ASKER

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
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....  :)
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?
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?
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
Okay im still getting the error 13 Permission denied in my error log  exec of ../hello.pl failed...
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.
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.
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
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.
okay removing
.htacces removed, apache restarted and still no go  :\
ASKER CERTIFIED SOLUTION
Avatar of bansidhar
bansidhar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
gee this is the fast solving case
lol