使用 PhpStorm 进行远程调试——不太正确的地方

Using PhpStorm for Remote Debugging - something not quite right

我按照此处的步骤在远程服务器上执行调试:

https://www.jetbrains.com/help/phpstorm/remote-debugging-via-ssh-tunnel.html

我在本地使用 MAC Sierra。

在 PhpStorm 中,我有 PHP 7.0 作为 CLI,它显示 Xdebug 已安装。在 php.ini 我有

zend_extension=/usr/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so
xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000

phpinfo 还显示 Xdebug 已启用。

Preferences->Languages->PHP->debug 下,我为 Xdebug 设置了端口 9000 并检查了 Enable remote connections。我也设置 Break at first line 只是为了确定。

我还通过我的 MAC 终端中的此命令建立了 SSH 隧道并 运行:

ssh -R 9000:localhost:9000 user@myremotesite.com

成功建立SSH连接。

我在我的本地计算机上重新启动了 Apache,在远程站点的 index.php 文件中设置了断点(虽然这相当于在本地文件中设置断点,但我的理解是它是如何工作的并且我有路径映射设置),启用侦听传入的调试连接,为 chrome 安装 xdebug 扩展并启用它,加载有问题的远程页面,但 PhpStorm 不会中断。

现在,根据说明,我没有看到必须在远程服务器上进行任何设置。我的理解是,如果我在完成所需步骤后在浏览器中键入地址,它将触发 PhpStorm 中的中断。

感觉好像少了什么。

想法?

如果您使用ssh -R 9000:localhost:9000 user@myremotesite.com,则表示您要调试的server/PHP位于myremotesite.com

据此,下列说法不正确的是:

Now, based on the instructions, I didn't see that I have to do any setup on the remote server.

您正在 远程 服务器上调试 PHP,这当然是您需要进行设置的地方。 Xdebug 存在于 PHP 中,因此需要在远程 Web 服务器上可用。

您需要在远程服务器上进行的设置应使其连接到暴露的 SSH 隧道端口。也就是说Xdebug需要连接的host/port是localhost:9000,不再是remote_ip。因此,这些设置应该有效:

xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_host=localhost

由于最后两个设置已经是默认设置,您甚至可以省略它们,直接使用 xdebug.remote_enable=1.

如果您想查看 Xdebug 的功能,请同时设置 xdebug.remote_log=/tmp/xdebug.log。这将记录连接尝试(如果存在)以及完整的通信。

I restarted Apache on my local computer

这也不需要,因为您的本地 Apache 不参与调试远程请求(即 运行 在 myremotesite.com 的 Apache 上的请求。