【问题标题】:XDebug not connecting on remote server (VSCode+php-debug+Remote SSH on local machine)XDebug 未连接到远程服务器(VSCode+php-debug+本地机器上的远程 SSH)
【发布时间】:2020-11-22 09:15:25
【问题描述】:

我正在尝试使用 VSCode、php-debug 扩展、本地计算机上的远程 SSH 和远程计算机上的 XDebug + PHP 7.3 设置远程调试。使用远程 SSH 我可以成功连接到远程机器,浏览和编辑代码。我的 launch.json 有两种调试模式:1)在当前脚本上启动; 2) 听 Xdebug。当我尝试使用第一种方法调试远程机器上的代码时,它工作得很好。我可以在当前机器上看到 php-debug 日志,在远程机器上也可以看到 xdebug 日志。但是当我在 VS Code 上的 Listen for XDebug 模式下启动调试器时,它看起来像是开始监听了。但是当我在浏览器上加载站点时,它不会在断点处停止。 xdebug 日志中也没有记录任何内容。

这就是我的 launch.json 的样子

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
    {
        "name": "Listen for XDebug",
        "type": "php",
        "request": "launch",
        "port": 9002,
        "log": true
    },
    {
        "name": "Launch currently open script",
        "type": "php",
        "request": "launch",
        "program": "${file}",
        "cwd": "${fileDirname}",
        "port": 9002,
        "log": true
    }
]

}

这是我在远程服务器上的 xdebug 配置

[XDebug]
zend_extension = "/opt/remi/php73/root/usr/lib64/php/modules/xdebug.so"
xdebug.remote_enable = 1
xdebug.remote_log="/tmp/xdebug.log"
xdebug.profiler_enable=0
xdebug.remote_connect_back=1
xdebug.remote_port=9002
xdebug.remote_autostart=1
xdebug.remote_handler=dbgp

请注意,我没有代码的本地副本,我也不想拥有。这就是这个设置的重点。

感谢您的帮助。谢谢

【问题讨论】:

  • 远程日志文件(/tmp/xdebug.log)对连接尝试有什么看法?
  • 您说“没有记录任何内容”,那么我相信您的 Web 服务器的 php.ini 变体没有 Xdebug 设置。通过浏览器检查phpinfo()的输出,看看它是否显示了所有正确的设置。

标签: visual-studio-code xdebug remote-debugging phpdebugbar


【解决方案1】:

对我来说,一个问题是 xdebug 正在侦听 TCPv6 端口但连接到 TCPv4 端口。 指定 "hostname":"localhost" 使其监听 TCPv4 端口

{
   "name": "Listen for Xdebug",
   "type": "php",
   "request": "launch",
   "stopOnEntry": false,
   "hostname": "localhost",
   "port": 9003,
   // server -> local
   "pathMappings": {
     "/var/www/": "${workspaceRoot}/",
   }
},

【讨论】:

    猜你喜欢
    • 2011-12-24
    • 2013-03-31
    • 1970-01-01
    • 2021-03-27
    • 2020-06-17
    • 2011-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多