Web Hosting Forum | Lunarpages

Author Topic: 500 Internal Server Error, all attempts with any CGI script  (Read 4358 times)

Offline kxssys0

  • Space Explorer
  • ***
  • Posts: 6
500 Internal Server Error, all attempts with any CGI script
« on: November 05, 2014, 02:08:05 PM »
My first attempts for a CGI perl script keeps failing with the '500 internal Server Error'. I have read everything I could find on this error on ?unarpages help and externally as well:

1- I made sure the file is in the cgi-bin folder with the proper permission (755).

2- I uploaded it using the control panel just to be sure it was done in ASCII mode. Plus, I changed FileZilla to ASCII mode instead of 'auto'.

3- The permission of the CGI script file is 755.

4- I made sure the first line is "#! /usr/bin/perl"

5- I checked for no outputted HTML syntax errors with a local test of "perl -wc <myscript>.cgi" and its clean.

6- I googled it and followed advice to make sure the first 3 HTML lines generated are:
#! /usr/bin/perl
print "Content-type: text/html\n";
print "<HTML>\n";
print "<HEAD><TITLE>Blah Blah</TITLE></HEAD>\n";
print "<H1> </H1>\n";
print "<H1> </H1>\n";

7- I added a simple .htaccess file to the cgi-bin folder, and verified its working with redirection:
DirectoryIndex index_good.html index.html

8- I logged the HTML output of the executed CGI script to a file, then tested it on my local PC with IE and Chrome to verify the page opens ok, and it does. So I know it is executing ok and producing proper HTML text.

I'm out of ideas at this point (hair pulling has begun!). Any ideas please? Thanks!



Online MrPhil

  • Senior Moderator
  • Berserker Poster
  • *****
  • Posts: 6210
Re: 500 Internal Server Error, all attempts with any CGI script
« Reply #1 on: November 05, 2014, 02:57:26 PM »
It's been a long, long time since I fooled with a Perl CGI script, but give these a try:

2. You can always check if the file uploaded correctly by browsing or editing it in the File Manager

4. Remove the space between ! and /. It's also possible that you're pointing to the wrong place. On your server, run the command find / -name perl -print 2>/dev/null (SSH command line, or a one-time cron job) to confirm where Perl is.

8. Is this the HTML produced by the CGI script, as run on the server cgi-bin, or produced locally on your PC?

How are you invoking your Perl script on the server?
Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-

Offline kxssys0

  • Space Explorer
  • ***
  • Posts: 6
Re: 500 Internal Server Error, all attempts with any CGI script
« Reply #2 on: November 10, 2014, 10:53:21 AM »
I figured out this problem by first testing with a non-HTML plain text 'Hello World' cgi script. (provided by LP, thank you). Then after that worked, I applied that to my original perl cgi script. The cause was erroneous use of the DOCTYPE HTML clause - when I removed it, all worked ok.  Thanks !

Online MrPhil

  • Senior Moderator
  • Berserker Poster
  • *****
  • Posts: 6210
Re: 500 Internal Server Error, all attempts with any CGI script
« Reply #3 on: November 10, 2014, 12:25:35 PM »
Was your DOCTYPE the very first line (before <HTML>)? Did you give an XHTML DOCTYPE with UPPERCASE tags? Did you have <BODY></BODY> and </HTML> tags?
Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-

 

Share |