Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Xdebug with PhpStorm and WSL

I use WSL (Ubuntu 16.14) from Windows 10 as a web server with PHP 7.1 fpm and Apache.

I want to use Xdebug from PhpStorm 2018 with WSL but it's not working well.

Xdebug is installed on my Ubuntu server and it works well, I see it on phpinfo() output.

Here the php.ini config for Xdebug:

[Xdebug]
zend_extension="/usr/lib/php/20170718/xdebug.so"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back=On
xdebug.remote_host=127.0.0.1
xdebug.remote_port = 9001
xdebug.idekey = PHPSTORM

I configured the port in php storm as 9001 too.

The problem is more on the connection between PhpStorm and WSL. I try it with the remote way. In the Run > Edit config popup, I use PHP Web Page and when I use the Validate tools, all is OK except the remote host. I set it to 127.0.0.1 and this is the point.

When I listen the debugging tools, it said : Port 9001 is busy

How can I do a link between localhost and localhost ?

like image 977
Tarkaros Avatar asked May 03 '26 10:05

Tarkaros


1 Answers

I am using WSL (Ubuntu 20.04 LTS) from Windows 10 as a web server with PHP 7.4 fpm and Apache with Xdebug Version 3.0.4

Following are the steps followed to configure the Xdebugger in the PHPSTORM and it works for me :

  1. Install the Xdebug

  2. select wsl in cli interpretor

  3. To get the client_host run the ifconfig in ubuntu or ipconfig in bash

  4. Open the below file

sudo vi /etc/php/7.4/cli/conf.d/20-xdebug.ini

add below in the above file

zend_extension=xdebug.so
xdebug.mode=debug
xdebug.client_host=[ip4 address/Client_host]
xdebug.remote_connect_back=On
xdebug.client_port="9003"
xdebug.remote_handler=dbgp
xdebug.start_with_request=yes
xdebug.remote_log=/tmp/xdebug.log

  1. Then use the Xdebugger chrome extension (xdebugger helper)

  2. Restart the apache server.

  3. Add the breakpoint to the file and refresh the page

like image 97
Renu Mishra Avatar answered May 06 '26 01:05

Renu Mishra