500 Internal Server Error

When you're writing CGI programs for the Web (C++ executables, Perl scripts at the like), you might sometimes get a 500 Internal Server Error The Server was unable to complete your request or somesuch. This essentially means that something went wrong, but no more than that. Even the error logs, if you have access to them, can be helpful if there's a genuine error in your program. However, all it might say is 'Premature End of Script Headers'.

This might mean that you forgot to send the regular HTTP response header(s) in your code, and this is covered ad nauseam on the Web already.

Less likely, it might mean that the permissions are wrong on the program or its parent directory (or directories). A CGI program must be readable and executable by the web server for it to run.

Much less likely, but suitably frustrating if you don't think of it, is that on some server configurations you'll get this error if the program isn't owned by the correct user, or is in the wrong group. root specifically may be disallowed. This may seem like security consciousness gone mad, but in truth it cuts down on hacking attempts -- usually by webmasters on shared servers, trying to sniff about the system.

Still stuck? There's one more thing that will give you the dreaded 500: The program is located in a directory outside of the 'allowed' web-space. The reason for this requirement is the same as for the user/group limitation above. You will simply have to copy the script to somewhere within the web server's allowed filespace. Even using symbolic links may not work.

You could of course get these situations with any program, but the one that you might feel inclined to install, and be relieved that it comes with its own configuration program, is awstats. It's a fine and dandy web-stats package, written purely in Perl; in fact, the awstats.pl script stands at over 500kB in size, plus other config-style library files. Despite being able to insert Apache directives and install itself into a location of your choosing, the installation script doesn't warn you about any of the above points. You will most likely end up with awstats installed in /usr/local/awstats and owned by root. Basically, having set your directives correctly in your webserver, and restarted the webserver as well, a 500 error when trying to run awstats.pl will most likely be a file ownership or location problem.

Remember, you must fix everything before it will work!


It's quiet in here...Add your comment



Recent Updates

07 Jul : Do It Yourself!
27 Oct : My Car Costs
13 Feb : Great Days Out
02 Sep : Nature
25 Nov : Piano for the Amateur
14 Nov : Measure
12 Oct : Simple Programming Exercises
11 Oct : Model Railways
01 Sep : The Developer's Apple Mac
21 May : Influencers
Laptop Questions
Your laptop make of choice?

Survey Results For US