WAMP Stack - Apache crashing on Windows Server

We have a client running a WAMP (Windows, Apache, MySQL, PHP)  stack on a Windows 2003 server. IIS and Apache are running off of two seperate IP addresses on this dedicated server and every so often Apache crashes. I constantly check the Apache error file typically located: [C:\Program Files\Apache Software Foundation\Apache2.2\logs\error.log] but have found no good reason why Apache is crashing except the following error messages:

Child 5184: Child process is exiting
Parent: Received shutdown signal — Shutting down the server.
Child 6924: Exit event signaled. Child process is ending.
Child 6924: Released the start mutex
Parent: Forcing termination of child process 432

Which is just telling me that Apache is crashing but not why. I am trying to pinpoint what the problem is but not sure how long I will have to Goolge search before I come up with the answer. In the mean time I have to manually restart Apache ever time it crashes. A website monitoring system would at least tell me when Apache crashes by emailing me or sending a txt to my cell phone but I would still have to manually log into the server and start Apache.

Wait a minute! I’m running IIS so why can’t I make my own monitoring script to check if a PHP website is up and running and if it’s not automaticlly start Apache and send an email/text message alert to whomever…

I made a simple PHP file called “check-apache.php” with the text “Apache is running!” in it and uploaded it to a PHP website ran on Apache. Then I created the following vbscript file:

on error resume next
Set xml = CreateObject(”Microsoft.XMLHTTP”)
xml.Open “POST”, “http://yourwebsite.com/check-apache.php”, False
xml.Send “”
TS=xml.responseText
set xml = nothing
If TS<>”Apache is running!”then
Dim oShell
Set oShell = WScript.CreateObject (”WScript.shell”)
oShell.CurrentDirectory =”C:\Program Files\Apache Software Foundation\Apache2.2\bin”
oShell.run “httpd -k start”
Set oShell = Nothing
Set objEMail = CreateObject(”CDO.Message”)
objEMail.To = “alert email addresses”
objEMail.From = “from emal address”
objEMail.Subject = “Apache Server Crashed”
objEMail.HTMLBody = now&”<br>”&Err.Number
objEMail.Send
Set objEMail = Nothing
End if

This vbscript uses a XMLHTTP request to check if the text “Apache is running!” exists in the returned value from /check-apache.php, if not then the command prompt is opened to start Apache with the “httpd -k start” command and emails are sent. This .vbs file is set up on a scheduled task to run every x minutes.  So the end result is if/when Apache crashes it will be back up within x minutes and I will be notified.

Leave a Reply

InfoLoop, LLC    |    © 2010 All Rights Reserved    |    Contact Us    |    Site Map