What does it mean when my CGIs fail with "Premature end of script headers" or "Internal Server Error"?

This means your script is not working correctly and it did not complete the action it was supposed to. Why does this happen? Well the most common reason is that the script does not have the proper permissions. What's probably happening is that when run on the command line, that script has the same permissions do, but when you run in the server, its permissions are equal to the permissions that the server has. One other issue which may arise is that the file you want to execute must be owned by the same user who owns the directory. To test this make two identical scripts in the directory being served. Leave one with the proper permissions and change the other to be owned by root and then execute the scripts and see what happens.