我需要在本地计算机上设置 Xdebug,它将连接到远程开发服务器。 我在 VScode 中的 launch.json 看起来像这样 -
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"hostname": "a.b.c.d", //Remote server IP
"port": 9000
}
]
}
我已将此代码添加到 /etc/php/7.2/cli/conf.d/20-xdebug.ini 文件
zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_handler = dbgp
xdebug.remote_port = 9000
xdebug.remote_host = 127.0.0.1
xdebug.remote_log=/var/log/xdebug.log
xdebug.remote_mode = req
xdebug.idekey="vsc"
我已经在浏览器中添加了 xdebug 扩展。 当我尝试单击 开始调试
时出现此错误Error: listen EADDRNOTAVAIL: address not available a.b.c.d:9000
code: 'EADDRNOTAVAIL',
errno: -4090,
syscall: 'listen',
address: 'a.b.c.d',
port: 9000
我有什么遗漏的吗?
这意味着其他东西已经在监听端口 9000。例如。 PHP-FPM。您需要将端口设置为其他端口,例如 9003,因为这是 Xdebug 3 使用的端口。然后,您需要在 VS Code
xdebug.remote_port
文件中的 "port" : 9003
和 launch.json
中使用 9003。