Separate Xdebug from php-fpm and nginx containers Separate Xdebug from php-fpm and nginx containers nginx nginx

Separate Xdebug from php-fpm and nginx containers


xdebug uses port 9000 by default, which conflicts with the PHP-FPM port.

You would need to change the assigned port of your PHP-FPM pool config or xdebug in php.ini. I recommend updating your PHP-FPM configuration to listen on a different port as it is less to configure for debugging with xdebug.

If you would like to change the port in PHP-FPM.

/php-fpm.d/pool.conf

[pool]listen = 127.0.0.1:9001

Update your NGINX configuration appropriately to use the new port.

Otherwise if you would like to change the xdebug port in PHP.

php.ini

[xdebug]xdebug.remote_port=9001

Update your debugging (PHP editor/IDE) software and firewall configuration to the new port. Alternatively use an SSH tunnel to forward the new remote port 9001 to the default local port 9000


As to your second question

xdebug only runs as an extension of PHP (php-fpm), if it is set to load in your PHP ini settings. It does not run as a separate background service.

Example:

[Browser Client -> http://example.com/path/to/script.php]    in -> [NGINX]         in -> [php-fpm /path/to/script.php] [xdebug remote host:port] <- out

or

[terminal command line]     in -> [php /path/to/script.php] [xdebug remote host:port] <-out

So yes, xdebug needs php-fpm or php-cli to run as they are one and the same.

If through Apache/NGINX that uses php-fpm, it will need to be loaded in your fpm configuration. If through the CLI interface, it would need to be loaded in your CLI configuration.

Keep in mind that you can run PHP with differing ini configurations based on environment. See PHP - The configuration file