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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

500 Server Error

Status
Not open for further replies.

RhythmAce

Technical User
May 22, 2001
2,869
FR
I've had my server running for a week and I still can't get it to serve CGI scripts (HTML pages are fine). I am running Apache 1.3.19 under RedHat Linux 7.1. Whenever I try to access the scripts through my browser, I get the 500 error page. My error_log says something like:

... [error](2) No such file or directory: exec of /path/to/script failed

... [error] [client xx.xx.xxx.xxx] Premature end of script headers: /path/to/script/

I get both lines each time I try to access a script. I've edited my httpd.conf file 'til I'm blue in the face and can't get it to work. I have ScriptAlias defined as well as the <Directory> block for my cgi-bin directory. I made sure to use the ExecCGI directive. I tried commenting and uncommenting the AddHandler but no luck there either. All path info is correct in the calling html pages and cgi scrips. I've tried typing their URLs directly into my browser but get the same result. I'm at the point where I'm going in circles now. I need someone to point my in new directions. By the way all file permissions are correct. I'm starting to thing the first error message is from the scripts themselves. Is it possible that they can't find perl or a perl module they need? I double checked and it is correct in the scripts (#!/usr/bin/perl). If I open a terminal and have perl execute the script from the command line, it just displays the text of the file. This makes me wonder if you can execute cgi locally. I hope someone out there can help me on this. I've even tried reinstalling everything from scratch and that didn't help either. I'm back where I was a week ago. I'd appreciate any help you can give me on this. Thanx
 
If you checked the perl executable path in your scripts, check if this cgi-bin directory is in a virtualhost container. If it is add this to your container:
<Directory &quot;/home/httpd/site/cgi-bin&quot;>
+ExecCGI
</Directory>

What you have to make sure is that the script works, the perl path is correct, permissions on the cgi/pl file (755), and that the directory has CGI executable permissions.


Hope this helps!!


Rninja
 
I checked everything in httpd.conf a hundred times and yes I did RTFM. :) After I couldn't get cgi-bin to work in my own directories, I went back to the defaults that Apache used for its test page and manual. My DocumentRoot is /var/ and my cgi-bin is /var/these are the settings I'm using:

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

If I use the ScriptAlias directive, then I use &quot;Options None&quot; in the Directory container. If I comment out the ScriptAlias, then I use Options ExecCGI and uncomment AddHandler cgi-script .cgi .pl. I've messed with a lot of combinations and still get the 500 error. The scrips themselves are ok because I tranfered them from another host I was using and they worked fine. I edited the path info in them to use my directory structure so they should work. I'm thinking the problem is with perl. I can't get any perl or cgi script to work, either from my browser or the command line. All I get is a display of the code itself. I checked the permissions on all the directories, scripts and perl itself. If I could get perl to work from the command line then I would know that the problem is in the Apache configs. I downloaded a few test scripts but none of them worked. Before I reinstall perl, does anybody know of a way to test perl to make sure it is working. I can type 'perl -V' from a terminal and it lists everything like it should but I can't get it to execute a script. It just displays the code. Is there a switch I'm supposed to us? Do I need to edit mime types? I'm at a total loss so any suggestions are welcome. Thanx.
 
If you type perl scriptname.cgi (where scriptname.cgi is your script), and it just shows code with no debugging info or execution.... Then you probably don't have the compiler installed properly/a corrupted library or something similar.
Try that out.

Hope this helps!!

Rninja
 
This may sound stupid -- but is your shebang line correct? Also, have you ran the script from the at command line level?
 
Never mind my last (memo to self: read all posts before answering).
 
I can quote the manual word for word, I've read it so many times. :eek:) I've tried every configuration known to mankind and still no luck. I also posted this problem in the perl forum hoping someone there can help me. I can't get cgi to execute from the command line either. So far they think it's a configuration problem and y'all (I live in Kentucky) think pretty much the same thing. I'm willing to post all my .conf files here if anyone cares to check them. :eek:) Is it possible something is not quite right with the install? I downloaded the ISO image files and installed from them. Does anybody know if there is a problem them installing everything correctly? Should I spring for a box set? :eek:) I really hope someone can point me in the right direction. I'm starting to feel pretty follish having 500 errors pop up when my visitors try to access my scripts.

 
Did you upload the files to the server or did you get them directly from the server? If they are uploaded remotely (especially a win box), you may see that there are extra return symbols or the text is wrapped and is not on the proper line, etc.


Hope this helps!!!

Rninja
 
Whoa. You said you couldn't execute the script from the command line? That would be where the 500 error is coming from... If the script dies, it does not send the necessary header information to Apache and thus, Apache returns the error. Nothing to do with configuration there.

You mentioned in your first post that you see the text of your program when you try to run it from the shell. This baffles me ... I can't think of a condition that would make that happen. But regardless, I'd do a thorough code audit. It doesn't appear that Apache is your source of grief.

Good luck.

brendanc@icehouse.net
 
Rninja, I think I shall call you my savior for you have shown me the foolishness of my ways. I originally had RedHat 6.0 as well as the version of Apache that came with it. I used ftp to transfer my website to my machine and it seemed to work ok. Then when I wanted to upgrade to version 7.1, I copied all my web files to my windows partition so I can do a clean install. Then I just copied them back. If I did corrupt all my files, is there an easier way to fix them than editing each one of them by hand? I got a zillion of them. Well thanks a lot for your help. I don't know if this is the cause of my problem but it sure makes sense. Maybe this is also why perl won't execute them from the command line. Well I'll check it out right now and let you guys know how it turns out. Thanks again.
 
Well check to see that the files are all case sensitive and if so are they all correct (lowercase as opposed to all upercase, etc...).
If they are all fine in case, check to see if the permissions are fine.
Lastly, check the script itself for problems. All lines that have comments should start with a &quot;#&quot; sign and the sentence should not wrap to the next line without a &quot;#&quot;. The make sure the path is right for the shebang (#!/usr/bin/perl or #!/usr/local/bin/perl).


Hope this helps!!!

Rninja
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top