Search code examples
phpstormxdebug

Breakpoints not working, PhpStorm on MAC, PHP running on Ubuntu server


I have an Ubuntu server running Apache and PHP7, with Xdebug installed and confirmed in the phpinfo():

          xdebug
xdebug support    enabled
Version           2.6.0
IDE Key           PHPSTORM

My PhpStorm is running on a Mac, a different machine. The webserver is running as it should. If I debug a PHP script from PhpStorm debugging also works fine. But if I add a breakpoint to my code in PhpStorm and run the PHP from a web browser the debugger doesn't seem to do anything. My code just executes. PhpStorm doesn't start debugging at my set breakpoint.

If I purposely add an error to my PHP code I can see by the output that Xdebug is doing something on the server, the error is presented in the xdebug-error table.

In the correct PHP.ini on the Ubuntu server I set the correct settings:

zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_autostart=1
xdebug.remote_host=192.168.0.130

So:

  • PhpStorm is listening for PHP Debug connections, or at least the "listen for debug connections" is enabled
  • Both are configures to listen/talk to port 9000
  • CLI interpreter is set correctly to the remote Ubuntu server
  • Path mapping is correct (in my case: /volumes/internet -> /var/www)
  • [Edit] Port scan on 9000 shows cslistener when PhpStorm is listening, when turned off there's nothing there

I would love to get my breakpoints working, what am I doing wrong?


Solution

  • xdebug.remote_host should not be set to the IP of the machine XDebug is running on, it should be set to the machine you're running PHPStorm on!

    Another option is to set xdebug.remote_connect_back to true. When this is enabled the xdebug.remote_host setting is ignored and Xdebug will try to connect to the client that made the HTTP request. It checks the $_SERVER['HTTP_X_FORWARDED_FOR'] and $_SERVER['REMOTE_ADDR'] variables to find out which IP address to use. (See the XDEBUG manual)