Forum Moderators: coopster & phranque

Message Too Old, No Replies

Internal 500 errors

         

zuzu_jane

5:35 am on Mar 1, 2007 (gmt 0)

10+ Year Member



I am in the process of moving my perl driven website to a new server. I am not a total dense head when it comes to cgi's (for example I know how to set permissions and upload in ASCII) but I am a noob about what I am dealing with in this instance.

I can not run any script through the browser but I can run in shell.

Then occasionally I am able to (intermittently) run a test script in the browser, then try to run another of my scripts and get a 500 error. When I return to the script that DID run ok, I then get a 500 error again.

Can anyone please shed some light? I am at wit's end, of course, as I have run these scripts for 5 years on a different server and am just having trouble on this new server. On Sunday everything ran ok, on Monday everything was broken!

Brett_Tabke

5:40 am on Mar 1, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Sounds like either an apache config issue, or permissions and ownership issues. All 3 can cause randomness of varying types. I totally sympathize - it can be difficult and maddening to determine the cause in these cases.

Put this near the top of your perl scripts

use CGI::Carp qw (fatalsToBrowser);

That will start to print errors to the screen.

In your apache config, turn on error logging and start watching the log files generated.

As for permissions - double check with your host as to the right permissions for your server box setup. It could be something nonstandard.

Also double check that the act used to upload the scripts. Can the web server execute scripts by that user?

zuzu_jane

6:08 am on Mar 1, 2007 (gmt 0)

10+ Year Member



Thanks for the fast reply -- I am frustrated that I am not getting support from the host.

I can not even run a test.pl script with simple code:

#!/usr/bin/perl

print "Content-Type: text/html";
print "<HTML><HEAD>";
print "<TITLE>CGI Test</TITLE>";
print "</HEAD>";
print "<BODY><H2>I just wrote a web page using Perl!</H2>";
print "</BODY></HTML>";

Where would I put the CGI::Carp qw (fatalsToBrowser);? as I tried and I still get a 500 error. I have the error logging on and I get only

[Thu Mar 1 06:06:13 2007] [error] [client 203.113.232.248] Premature end of script headers:

Driving me bonkers!

Brett_Tabke

6:13 am on Mar 1, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



just put it above the content type line.

THe content line should be

print "Content-Type: text/html\n\n";

You need to print 2 returns after the content type there. THat is what the \n\n does. That tells the web server that the content starts and no more server commands.

zuzu_jane

6:23 am on Mar 1, 2007 (gmt 0)

10+ Year Member



I did what you suggested and still 500 errors.

I have a test directory with nothing but .pl and .cgi files in it called /test. The server is set up as such through a webhosting panel:

CGI aliases
.cgi
.pl

CGI dir aliases
/test -> /test
/cgi-bin -> /cgi-bin

Still unable to run even that simple .pl file. I am not exactly sure what to ask the host to do. I have put in a support ticket saying that I am not able to run simple scripts. No response -- that was 5 hours ago.

Brett_Tabke

6:37 am on Mar 1, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Sounds like a permissions issue.

Try swapping them around from 777, to 755,

rocknbil

8:07 am on Mar 1, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



but I can run in shell

Try this. Navigate to the directory of the script,
cd /var/www/html/cgi-bin
or whatever. Make SURE you are in the right directory,
ls -a

Now execute a command line editor,

nano test.pl
or
pico test.pl

or .cgi, or whatever. If you see a blank screen, you got the filename wrong, CTRL-X to exit and try again. For either of these, once you see the script in the editor window, press CTRL-O (letter O) to write out, press enter to overwrite the script. CTRL-X to exit.

Try calling the script now. If it works, here is what I suspect: your text editor is saving PC style end-of-line characters. I learned long ago to always use an editor that has the capability to save in Unix format. Then when you upload in ASCII, no problems. I started off with HTMLed, which has zero support and limited use as an HTML editor, and now exclusively use HomeSite.

If it does not, try
#!/usr/local/bin/perl

Although by the sounds of it you have the path to perl right, you got it to work once. I'm betting on the end-of-line characters.

And of course chmod 755 [filename.] :-)

And by the way zuzu_jane, welcome aboard! (Shame on you Mr, Tabke. :-) )

zuzu_jane

12:24 pm on Mar 1, 2007 (gmt 0)

10+ Year Member



No it isn't the PC style end of line character things. In the shell I just created a perl script in pico, saved -- chmod to 755 -- executed in the shell -- no worries, it ran. Try in the browser and get internal server 500 error.

Should I be asking the server host to set some permissions that I haven't got access to change?

wruppert

1:44 pm on Mar 1, 2007 (gmt 0)

10+ Year Member



Did you look at the Apache error log after you fixed the content line?

zuzu_jane

8:39 pm on Mar 1, 2007 (gmt 0)

10+ Year Member



Apparently the server host is upgrading the version of Apache. If I am still continuing to have problems they will move me to another server. You see the funny thing is that everything worked when I set it up on Sunday -- on Monday it was intermittently running scripts, and by Tuesday it was completely broken.

I have done the usual trouble shooting -- carriage returns, correct permissions, execute the script in the shell etc etc to no avail. It was frustrating enough for me to post here for some expert help. The simple little test scripts won't even run.

Appreciate all the help and I will update after the Apache upgrade.

zuzu_jane

6:37 am on Mar 3, 2007 (gmt 0)

10+ Year Member



UPDATE: The scripts are now running fine as the version of Apache has been upgraded to the latest stable version. What this had to do with anything I can't answer!

I had 6 days of agonising chmod, checking scripts etc etc etc but it seems to be ok now. Thanks all for your replies and help.

zuzu jane