phpstorm与xdebug的连接

Connection between phpstorm and xdebug

我配置了 phpstorm-xdebug 并且我能够使用断点调试我的代码。 这些天我更新了 php(通过 brew)和 xdebug,现在我有 php 5.5.26 和 xdebug 2.3.3。 当我尝试调试测试(和代码)时 phpstorm 告诉我:"connection with xdebug was not established".

我已经在php.ini检查了xdebug的配置,如下

[xdebug]
zend_extension="/usr/local/opt/php55-xdebug/xdebug.so"
xdebug.remote_enable=1
xdebug.profiler_enable=1
xdebug.remote_port=9000
xdebug.remote_host=127.0.0.1
xdebug.idekey=PHPSTORM

Web 服务器调试验证显示

我尝试了不同版本的 phpstorm,卸载并重新安装 php55/php55-xdebug 但没有成功。

你知道如何解决这个问题吗?

安装新的PHP后,如果没有正确配置就启动php-fpm,默认监听9000端口,这里是'stock'php-fpm.conf 来自您需要编辑的发行版:

/usr/local/etc/php/5.5/php-fpm.conf

...

;   '[::]:port'            - to listen on a TCP socket to all addresses
;                            (IPv6 and IPv4-mapped) on a specific port;
;   '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = 127.0.0.1:9000

它绑定了端口9000,把它改成另一个值(在我的例子中改成8001)。然后相应地配置你的apache的配置。这是我的配置示例配置 (apache 2.4),绑定到端口 8001

/usr/local/etc/apache2/2.4/extra/proxy-fcgi.conf

ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:8001/usr/local/var/www/htdocs/
DirectoryIndex /index.php

重新启动 apache 和 php-fpm,您可以使用端口 9000 进行 xdebug。启动 PhpStorm。

另一种解决方法——更改php.ini中xdebug的端口。例如给 9001:

xdebug.remote_port=9001

之后,您需要在 Preferences->Languages & Frameworks -> PHP -> Debug 中更改 PhpStorm 中的 xdebug 端口。 Xdebug 端口设置为 9001。

php.iniphpstorm中也更改xdebug.remote_port=9001,为我工作。