XDebug and PHP-FPM configuration

Configuring XDebug on a PHP-FPM powered server.

The problem

I’ve set up a new local development environment following this excellent guide and all went smooth until I could not debug my code using XDebug.


php --version

The above command does show that XDebug is installed and running but the until then working PhpStorm configuration stopped working. XDebug is installed

Shut door

The issue lies in the port that’s used by XDebug by default to connect to servers: the 9000 one; PHP-FPM is listening on that port already and the following command will show it

lsof on port 9000 shows PHP-FPM is listening

XDebug allows for the configuration of another port to use so that’s not an issue; I’ve modified my XDebug configuration file to use the port 9009 in place of the default one

[xdebug]
zend_extension="/usr/local/opt/php56-xdebug/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_host="localhost"
xdebug.remote_handler=dbgp
xdebug.remote_port=9009
xdebug.remote_autostart=1

and made sure that PHPStorm will listen on that. PHPStorm set to listen for XDebug on port 9009 The game is done.