1
votes

When I tried accessing my "hello world" perl script (hello.cgi) via the browser, the browser gives the 500 Internal Server Error.

However, when I changed the file ending of that same file to hello.pl, I can access it just fine via the browser. I also tried troubleshooting this with a python script (hello.py) in the same directory and it works just fine.

I've changed the httpd.conf with the following:

AddHandler cgi-script .cgi .py .pl

AllowOverride None SetHandler cgi-script Options +ExecCGI Order allow,deny Allow from all

I've looked everywhere to resolve this problem, but nothing seems to work. Please help.

3
Besides the web page error message, the Apache server logs can give you some additional clues when troubleshooting CGI scripts, specifically the error log for the site/virtual host. Just FYI.Sdaz MacSkibbons

3 Answers

1
votes

Make sure the shebang line is correct. The Apache server has to know where your perl interpreter is, i.e. where perl.exe is. If perl.exe isn't in /usr/bin/perl (like your shebang says) then it won't work.

I wasn't getting anything until I changed my shebang to #!C:/Program Files (x86)/Perl64/bin/perl.exe

(btw I know what it is like to look for ages for help with these things. Good luck!)

1
votes

I would recommend:

  • Giving the script execute permissions using GoDaddy's web-based File Manager
  • If you are using Hosting Configuration prior to 2.0 then I believe your perl scripts can only be located in the cgi directory. Upgrade to 2.0+ and your perl scripts can reside anywhere on your hosting account.
  • Try to resave the perl script with unix line endings, or try editing it and saving it with GoDaddy's web-based File Manager (this is what ultimately worked for me)
  • As mentioned previously, it could also be incomplete HTTP headers being sent
  • If all else fails turn on error logging in the Hosting Manager and you will see a directory called Error Logs in the File Manager that should help you further.
0
votes

You probably forgot print "Content-Type: text/html\n\n" or somesuch.