Account

Log in (OpenID enabled)

Tips for Monitoring PHP

Category: IT   Tags: , ,

Just a couple hours ago, you may have noticed that this website was showing blank pages.

For some reason, PHP decided to stop working. Every PHP page was blank. I simply restarted it, and it worked again.

Unfortunately the error-logs are disabled for PHP in the default “production site” configuration. So be sure to enable that option.

Another option is to use Monit to monitor whenever PHP stops working. The trick is to use the “checksum” option:

[Usual monit php configuration here]
  if failed host www.codexon.com port 80
    protocol http and request "/monit.php"
      with checksum 5eb63bbbe01eeed093cb22bb8f5acdc3
      then restart

Where checksum is the MD5 value of the file. Then we create monit.php.

<?php
echo "hello world";
?>

So whenever PHP starts choking and serving blank pages, Monit will restart your PHP for you.

For those interested, this is the PHP I am running. All of which are from the Ubuntu 9.04 repository.

PHP 5.2.6-3ubuntu4.1 with Suhosin-Patch 0.9.6.2 (cli)
(built: Apr 23 2009 14:37:14)

APC 3.0.19-2
  • Reddit
  • HackerNews
  • Twitter
  • DZone
  • del.icio.us
  • FriendFeed
  • StumbleUpon
  • RSS

Related posts:

  1. Debunking Google’s Internet Optimization Tips
  2. Defending Against the New DOS Tool Slowloris
  3. PHP Sucks: No stable sort
  4. Backlash From Stackoverflow Reputation Tips
  5. 6 Simple Tips to Get Stackoverflow Reputation Fast

1 Comment  »

  1. Maybe try cacti monitoring would be a good idea?

    http://artur.ejsmont.org/blog/content/palm-v3-bundle-of-php-apache-linux-and-memcached-monitoring-scripts-and-cacti-graphs-apc

    You get all graphs for free and with minimal efford you can create new gathering script to load home page or whatever and make sure response code is 200 and page contains some strings or whatever.

    once i fell in love with cacti there is no way back :- )

    art

RSS feed for comments on this post, TrackBack URI

Leave a Comment

(Cookies must be enabled)