« Carnival of Life | Main | Bizarre Factoid Hidden in Poll Results »

August 31, 2005

Windows Hell - Important Safety Tip for Apache Under Windows

by Ferdinand T Cat

Well, Bruce spent another night in Windows Hell, so I thought I'd better post the details so that other Windows users can benefit from his pain and so that all the MacIntosh people can feel even better about their choice of equipment.

The short story is: never modify the error log file while the server is running.

Bruce uses a program called Apache to create a web server on his laptop that he can use for testing purposes. Apache is an Open Source product, which means that it's provided free of charge. Almost every web server in the world uses either Apache or Microsoft's Internet Information Server, but as you can imagine, Apache is much more cost-effective for nearly every application.

When you're running a program that builds a web page and something goes wrong, nine times out of ten all you see is a page with the rather terrifying message 500 Internal Server Error. There is absolutely no useful information on the 500 Error page; instead, the description of the error goes in a special file called the error log. An actual error log looks something like this:

[Wed Aug 31 04:55:59 2005] [notice] Apache/2.0.54 (Win32) configured -- resuming normal operations
[Wed Aug 31 04:55:59 2005] [notice] Server built: Apr 16 2005 14:25:31
[Wed Aug 31 04:55:59 2005] [notice] Parent: Created child process 4344
[Wed Aug 31 04:55:59 2005] [notice] Child 4344: Child process is running
[Wed Aug 31 04:55:59 2005] [notice] Child 4344: Acquired the start mutex.
[Wed Aug 31 04:55:59 2005] [notice] Child 4344: Starting 250 worker threads.
[Wed Aug 31 04:56:27 2005] [error] [client 127.0.0.1] Premature end of script headers: index.cgi
[Wed Aug 31 04:56:27 2005] [error] [client 127.0.0.1] Tracing open for ">>M:\trace.log" failed: Invalid argument at C:/Documents and Settings/Bruce/My Documents/FIGWin/lib/Tracer.pm line 674.

It may appear to be gobbledy-gook, but to a web developer the information is the difference between a quick fix and a night in hell.

If you've been working for a long time, the error log file gets pretty large, and you may be tempted to erase the contents so that the old, stale messages give way to new, fresh messages.

Resist this temptation at all costs. Apache apparently remembers its position in the file, and the next time it tries to write to the error log, the server will hang.

The truly knee-slapping funny part about this is that the normal method for locating the cause of a hang is to write extra messages to the error log to see where the problem is occurring. The joke is, no matter where you put the extra message, it's going to hang right in front of it.

Stopping and re-starting the server fixes the problem.

Respectfully submitted,

Ferdinand T. Cat


# At Wed 5:57 AM | Permalink | Trackback URI | Comments (1) | More Windows Hell

Trackback Pings

Comments

This works fine if you stop the web server first, then restart it.
This is also a windows-only issue, FYI. This is why I use an Apple Powerbook so that Apache, MySQL, Perl, PHP all run purrfectly.

you could also monkey with the log file rotation schedule so you
don't have to manage this.

Thanks for the great website!!


Posted by: anon at October 3, 2005 6:05 PM

HTML is not allowed in comments; however, if you put in a raw URL (http://www.somewhere.com/page.html) it will automatically be converted to a link.. Also, it is likely your comment will not appear unless you refresh the page manually after posting it.

Post a comment