Craig Marvelley

Software and such

Deactivating a Macports Install of XDebug in a LAMP Environment

A few times I’ve found myself cursing when trying to toggle XDebug on and off via Macports. Typically I’ll be debugging with it enabled, then disable it for development/testing to get the fastest experience possible (it tends to really impact performance on large codebases, such as a Symfony2 standard install), only to experience segfaults when I refresh the page I’m working on.

The solution I’ve found is when restarting Apache (which is necessary for the change to PHP’s installed modules takes effect), to use an explicit start/stop rather than a restart. According to the Apache docs restarting only kills off children processes, so the parent remains running:

Sending the HUP or restart signal to the parent causes it to kill off its children like in TERM, but the parent doesn’t exit. It re-reads its configuration files, and re-opens any log files. Then it spawns a new set of children and continues serving hits.

I imagine this leading to a discrepancy in the loaded PHP modules, which causes the issue.

So when wanting to toggle XDebug, I use these commands:

Install (first time only):
sudo port install php5-xdebug

sudo port deactivate php5-xdebug
sudo apachectl stop
sudo apachectl start

sudo port activate php5-xdebug
sudo apachectl stop
sudo apachectl start