2 回答

TA貢獻(xiàn)1779條經(jīng)驗 獲得超6個贊
看起來其他東西已經(jīng)在監(jiān)聽端口 9000,因此,VS 也無法打開相同的端口進(jìn)行監(jiān)聽。這很可能是 PHP-FPM。
要解決此問題,請在 php.ini 中設(shè)置以下內(nèi)容:
xdebug.remote_port=9003
并將 VS 配置(兩次)更改為相同的端口:
"port": 9003,

TA貢獻(xiàn)1804條經(jīng)驗 獲得超7個贊
該問題與防火墻阻止傳入連接有關(guān)。為我解決了以下步驟:
安裝 UFW -
sudo apt-get install ufw
sudo ufw enable
sudo ufw allow 9000/tcp
在我的 Php.ini 中,我使用以下設(shè)置:
[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 有以下內(nèi)容:
{
// 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 假設(shè)工作空間指向源數(shù)據(jù)的根,并且它沒有隱藏在子文件夾中。
最后,您將需要添加 UFW 規(guī)則以遠(yuǎn)程訪問您的 Web 服務(wù)器,因為安裝后這些默認(rèn)情況下在 UFW 中不存在
sudo ufw app list
sudo ufw allow 'Apache Full'
我還使用該方法從我的應(yīng)用列表中添加了其他規(guī)則。
我希望這可以幫助像我這樣在新啟動的 Ubuntu 18.04.4 VM 上努力連接到 xDebug 的人。
- 2 回答
- 0 關(guān)注
- 170 瀏覽
添加回答
舉報