2 回答

TA贡献1779条经验 获得超6个赞
看起来其他东西已经在监听端口 9000,因此,VS 也无法打开相同的端口进行监听。这很可能是 PHP-FPM。
要解决此问题,请在 php.ini 中设置以下内容:
xdebug.remote_port=9003
并将 VS 配置(两次)更改为相同的端口:
"port": 9003,

TA贡献1804条经验 获得超7个赞
该问题与防火墙阻止传入连接有关。为我解决了以下步骤:
安装 UFW -
sudo apt-get install ufw
sudo ufw enable
sudo ufw allow 9000/tcp
在我的 Php.ini 中,我使用以下设置:
[dDebug]
zend_extension = /usr/lib/php/20190902/xdebug.so
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 1
xdebug.remote_port=9000
最后,我的启动 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": 9000,
"pathMappings": {
"/var/www/html/YourApp": "${workspaceRoot}/"
}
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
]
}
JSON 假设工作空间指向源数据的根,并且它没有隐藏在子文件夹中。
最后,您将需要添加 UFW 规则以远程访问您的 Web 服务器,因为安装后这些默认情况下在 UFW 中不存在
sudo ufw app list
sudo ufw allow 'Apache Full'
我还使用该方法从我的应用列表中添加了其他规则。
我希望这可以帮助像我这样在新启动的 Ubuntu 18.04.4 VM 上努力连接到 xDebug 的人。
- 2 回答
- 0 关注
- 180 浏览
添加回答
举报