断点不起作用,PhpStorm 在 MAC、PHP 运行 服务器上 Ubuntu
Breakpoints not working, PhpStorm on MAC, PHP running on Ubuntu server
我有一个 Ubuntu 服务器 运行ning Apache 和 PHP7,安装了 Xdebug 并在 phpinfo() 中确认:
xdebug
xdebug support enabled
Version 2.6.0
IDE Key PHPSTORM
我的 PhpStorm 运行在另一台 Mac 机器上运行。网络服务器正常 运行ning。如果我从 PhpStorm 调试 PHP 脚本,调试也可以正常工作。但是,如果我在 PhpStorm 中为我的代码添加一个断点,并且在 Web 浏览器中添加 运行 PHP,调试器似乎不会执行任何操作。我的代码只是执行。 PhpStorm 没有在我设置的断点处开始调试。
如果我故意在我的 PHP 代码中添加一个错误,我可以从输出中看到 Xdebug 正在服务器上执行某些操作,该错误显示在 xdebug-error table 中。
在 Ubuntu 服务器上的正确 PHP.ini 我设置了正确的设置:
zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_autostart=1
xdebug.remote_host=192.168.0.130
所以:
- PhpStorm 正在侦听 PHP 调试连接,或者至少 "listen for debug connections" 已启用
- 两者都配置为 listen/talk 端口 9000
- CLI 解释器已正确设置为远程 Ubuntu 服务器
- 路径映射正确(在我的例子中:
/volumes/internet
-> /var/www
)
- [编辑] 当 PhpStorm 正在侦听时,9000 上的端口扫描显示 cslistener,关闭时什么也没有
我很想让我的断点起作用,我做错了什么?
xdebug.remote_host
不应设置为 XDebug 运行 所在机器的 IP,它应设置为 运行 PHPStorm 所在的机器!
另一种选择是将 xdebug.remote_connect_back
设置为 true
。启用后,xdebug.remote_host
设置将被忽略,Xdebug 将尝试连接到发出 HTTP 请求的客户端。它检查 $_SERVER['HTTP_X_FORWARDED_FOR']
和 $_SERVER['REMOTE_ADDR']
变量以找出要使用的 IP 地址。 (See the XDEBUG manual)
我有一个 Ubuntu 服务器 运行ning Apache 和 PHP7,安装了 Xdebug 并在 phpinfo() 中确认:
xdebug
xdebug support enabled
Version 2.6.0
IDE Key PHPSTORM
我的 PhpStorm 运行在另一台 Mac 机器上运行。网络服务器正常 运行ning。如果我从 PhpStorm 调试 PHP 脚本,调试也可以正常工作。但是,如果我在 PhpStorm 中为我的代码添加一个断点,并且在 Web 浏览器中添加 运行 PHP,调试器似乎不会执行任何操作。我的代码只是执行。 PhpStorm 没有在我设置的断点处开始调试。
如果我故意在我的 PHP 代码中添加一个错误,我可以从输出中看到 Xdebug 正在服务器上执行某些操作,该错误显示在 xdebug-error table 中。
在 Ubuntu 服务器上的正确 PHP.ini 我设置了正确的设置:
zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_autostart=1
xdebug.remote_host=192.168.0.130
所以:
- PhpStorm 正在侦听 PHP 调试连接,或者至少 "listen for debug connections" 已启用
- 两者都配置为 listen/talk 端口 9000
- CLI 解释器已正确设置为远程 Ubuntu 服务器
- 路径映射正确(在我的例子中:
/volumes/internet
->/var/www
) - [编辑] 当 PhpStorm 正在侦听时,9000 上的端口扫描显示 cslistener,关闭时什么也没有
我很想让我的断点起作用,我做错了什么?
xdebug.remote_host
不应设置为 XDebug 运行 所在机器的 IP,它应设置为 运行 PHPStorm 所在的机器!
另一种选择是将 xdebug.remote_connect_back
设置为 true
。启用后,xdebug.remote_host
设置将被忽略,Xdebug 将尝试连接到发出 HTTP 请求的客户端。它检查 $_SERVER['HTTP_X_FORWARDED_FOR']
和 $_SERVER['REMOTE_ADDR']
变量以找出要使用的 IP 地址。 (See the XDEBUG manual)