我知道这个问题已经被问过很多次了,但我尝试了 20 个其他解决方案,花了一整天的时间,但似乎没有任何效果。
我的 WSL2 在 Ubuntu 20.04 上运行 PHP 7.4 + Xdebug 2.9.2,并在新的 Windows 11 上使用 PhpStorm 2021.2。
php.ini
zend_extension="/usr/lib/php/20190902/xdebug.so"
xdebug.remote_enable=1
xdebug.start_with_request=trigger
xdebug.discover_client_host=no
xdebug.idekey=PHPSTORM
xdebug.remote_port=9003
xdebug.remote_log="/var/log/xdebug/xdebug.log"
xdebug.remote_host=172.19.144.1
日志
[29220] Log opened at 2022-01-10 18:54:56
[29220] I: Connecting to configured address/port: 172.19.144.1:9003.
[29220] E: Time-out connecting to client (Waited: 200 ms). :-(
[29220] Log closed at 2022-01-10 18:54:56
$ cat /etc/resolv.conf // nameserver 172.19.144.1