簡體   English   中英

無法讓 PhpStorm 連接到在 WSL 2 中運行的 Xdebug

[英]Unable to get PhpStorm to connect to Xdebug running in WSL 2

我無法通過以下設置使 PhpStorm 2020.2 與 xdebug 一起使用:WSL2 運行 Ubuntu 20,安裝了 PHP 和 php-xdebug。 每當我在啟用調試的情況下運行測試時,它都會顯示“未建立連接。”。

這是 Xdebug 日志顯示的內容:

[5877] Log opened at 2020-08-14 17:20:45
[5877] I: Connecting to configured address/port: 172.18.48.1:9006.
[5877] E: Time-out connecting to client (Waited: 200 ms). :-(
[5877] Log closed at 2020-08-14 17:20:46

這僅適用於 CLI ,我不嘗試通過 php-fpm 連接(所以沒有 Apache、nginx,...)。

到目前為止,我已經嘗試過:

  • 將端口更改為 9000 以外的端口(端口掃描還顯示它們都沒有被使用)。

  • 添加防火牆規則以允許傳入請求,如https://github.com/microsoft/WSL/issues/4585#issuecomment-610061194中所述(以及在添加規則后重新啟動幾次)

     New-NetFirewallRule -DisplayName "WSL" -Direction Inbound -InterfaceAlias "vEthernet (WSL)" -Action Allow
  • 將諸如xdebug.remote_enable=1之類的選項添加到配置中,但這無論如何都是由 PhpStorm 在運行遠程 php 實例時完成的( remote_connect_back也沒有做到這一點):

     [wsl://UBUNTU2004]:php -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9006 -dxdebug.remote_host=172.18.48.1 /home/spaceemotion/code/xxxxxx/backend/vendor/phpunit/phpunit/phpunit [rest ommitted]

任何幫助將非常感激!

根據: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360000436444/comments/360000168070

在 Windows 控制面板 > Windows 防火牆 > 允許程序或功能通過 Windows 防火牆中,您可以看到允許通過專用網絡和公共網絡進行通信的軟件列表。

確保實際允許使用 phpstorm.exe(對我來說,未選中專用網絡選項)。

將 Xdebug 與 PhpStorm 和 WSL 一起使用

它對我有幫助,也對 xdebug.org/wizard 有幫助

只需按照這些頁面

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM