You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

群晖NAS上Xdebug配置VSCode单步调试故障排查

启用并配置群晖NAS上的Xdebug,实现VSCode单步调试PHP代码

在phpinfo()中能看到Xdebug模块,推测群晖NAS已安装Xdebug。

Version 3.1.2
Development Helpers ✔ enabled
Coverage    ✘ disabled
GC Stats    ✘ disabled
Profiler    ✘ disabled
Step Debugger   ✘ disabled
Tracing ✘ disabled
xdebug.client_host  localhost
xdebug.client_port  9003

更新

已进行以下操作,但问题仍未解决:

  • DSM版本:7.2-64570 Update 1
  • 在Web Station的脚本语言服务中创建新的PHP配置文件(Dev Xdebug),并在核心标签页设置Xdebug参数:
    xdebug.mode = develop,debug
    xdebug.start_with_request = yes
    xdebug.client_port = 9003
    
  • 在Web服务中将网站服务配置切换为Dev Xdebug。

此时通过phpinfo()可看到Development Helpers和Step Debugging已启用,但VSCode仍忽略断点。

在Listen for Xdebug配置中添加"hostname": "localhost"后调试可启动,但仍不识别断点;设置"hostname": "<NAS名称>"或"hostname": "<IP地址>"时,启动调试会报错:

listen EADDRNOTAVAIL: address not available IP_Address:Port#

尽管NAS的IP地址正确,且已关闭PC和NAS的防火墙,问题仍存在。

VSCode的launch.json配置如下:

"version": "0.2.0",
"configurations": [
    {
        "name": "Listen for Xdebug", 
        "type": "php",
        "request": "launch",
        "port": 9003    
    },
    {
        "name": "Launch currently open script",
        "type": "php",
        "request": "launch",
        "program": "${file}",
        "cwd": "${fileDirname}",
        "port": 0,
        "runtimeArgs": [
            "-dxdebug.start_with_request=yes"
        ],
        "env": {
            "XDEBUG_MODE": "debug,develop",
            "XDEBUG_CONFIG": "client_port=${port}"
        }
    },
    {
        "name": "Launch Built-in web server",
        "type": "php",
        "request": "launch",
        "runtimeArgs": [
            "-dxdebug.mode=debug",
            "-dxdebug.start_with_request=yes",
            "-S",
            "localhost:0"
        ],
        "program": "",
        "cwd": "${workspaceRoot}",
        "port": 9003,
        "serverReadyAction": {
            "pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
            "uriFormat": "http://localhost:%s",
            "action": "openExternally"
        }
    }
]

寻求其他解决方案。


内容的提问来源于stack exchange,提问作者bbProg

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.11 12:35:23