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 關注
- 189 瀏覽
添加回答
舉報
