500 Internal Server Error

07 May 2005 | Comment

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!


Comments

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

Rackspace Cloud Hosting

Rackspace Cloud Hosting Using Rackspace Cloud Servers for your web hosting is the perfect solution for the budget-conscious startup with good growth capabilities - but as long as you know how to run a server. Windows server images are available ... (more)

mod_pagespeed breaks things

Google is respected in the web development community for writing simple, usable code and then making it available for re-use by everyone. mod_pagespeed is just an example of this; it's a plugin module for the Apache web server, and is supposed ... (more)

Google +1 for all Websites

Webmasters can now put Google's "like competitor" +1 on their web pages. Many webmasters will groan with trepidation at the thought of having to squeeze yet another piece of social javascript junk onto their beautifully crafted pages, but ... (more)

How Windows Determines Your Internet Access

If you've ever wondered how Microsoft Windows knows whether you have a solid Internet connection or not, it isn't magic: Windows networking is programmed to attempt connection to a TCP service. It uses the success or failure of this to report ... (more)

Faulty iPhone out of Warranty? Help is at Hand!

UK consumers have a powerful friend in the Sale of Goods Act, if something they buy fails unexpectedly within a fairly long period of time - up to six years, in fact. What does this mean if you have an iPhone that has stopped working ... (more)

Rasmus Lerdorf: Founder of PHP

Greenland has its very own computing influencer! Way back in 1995, Rasmus Lerdorf got PHP (PHP Hypertext Preprocessor) off the ground and thus paved the way for a blindingly simple way to do web programming. PHP placed the emphasis of website ... (more)

Hands-free Phone doesn't mean Both Hands off the Wheel!

I recently had the misfortune to witness an Environment Agency employee driving along, in an Environment Agency truck, playing with his phone on his lap, with no hands on the wheel! I saw this clearly as I was sat at an upstairs window in ... (more)

Is there such a thing as a Free Credit Score?

If you want to find out your credit score, you generally have to pay for it. Information about you, held by companies such as Experian, is used to determine whether you are a risky person to lend money to. It's clearly in your interests to ... (more)

Rackspace Ups and Downs

You pay a lot of money for Rackspace managed hosting. You pay for decent hardware in a top-notch data centre, with great Internet connectivity and of course fanatical support. If your web service demands low latency and minimal downtime ... (more)

Geo-targetting your website

Does your company have a local presence in many different countries, or do you run a site where it makes sense to keep visitors from different countries away from each other? There are a number of follow-on questions here. Does it matter ... (more)

Live Script Run Times for Swinny.net

Here is a summary of the time it takes the Swinny.net server to run a PHP script to deliver a web page, over the last few weeks. The site was hosted on Mediatemple (gs) service, as up until 27 October 2010. From 28 October onwards the site ... (more)

Backup costs

The Rackspace Cloud Servers platform has a convenient backup snapshot system, for the smaller-sized instances. These can be images both on-demand (snapshots) and scheduled (backups) of the Cloud Server. Until recently some customers have not ... (more)

Get a CentOS Server Web-Ready

Here are the command-line steps needed to get a bare Rackspace Cloud CentOS 5.5 image ready for full LAMP (Apache-MySQL-PHP) hosting: (Note - replace mysite.com with the domain name of your own website) yum install rsync yum install mysql ... (more)

Intel Power Web API

The Intel Power Web API provides a web app with JavaScript access to information about the device's power and battery state. For instance, in combination with other information about the device, a web app might use connection information ... (more)

Recent Updates:

19 May : Heating Oil Thefts - Stay Alert!
19 May : Pro Blaze Overshoes pass the test
15 May : Get a CentOS Server Web-Ready
13 May : Keeping your iPhone secure
06 May : Nero, Claudius and a rather dead mouse
19 May : Domestic Heating Oil Prices: Know the Market!
19 May : Sports Gear: Under Test
15 May : Rackspace Cloud Hosting
13 May : iPhone 4
06 May : Cats
19 Mar : Time Trial Results
25 Nov : Piano for the Amateur
14 Nov : Measure
02 Nov : Book Reviews
12 Oct : Simple Programming Exercises
Laptop Questions
Your laptop make of choice?







Survey Results For US
 

Popular Searches: