0
votes

I've got problems with setting up Remote Web Server Debugging with Xdebug. I keep getting 404 error:

enter image description here

but actually Xdebug is being detected correctly:

enter image description here

How are machines setup

  • Laptop and Desktop PC are connected in the same network
  • Laptop has Ubuntu 18 installed and I'm using it as server
  • There is a Docker on laptop with file sync but this doesn't matter at this point
  • PhpStorm is on my Desktop PC,
  • Vsftpd is configured correctly, files edited on Desktop are being sent on laptop and page data is being update in container,
  • my website works locally at 192.168.1.103

What works fine at this point

  • FTP connection with laptop,
  • SFTP connection with laptop,
  • SSL,
  • SSH connection from desktop via for example Git Bash,
  • Xdebug itself works fine on laptop.

What I already tried


    zend_extension=/usr/lib/php/20170718/xdebug.so
    xdebug.remote_autostart = 1
    xdebug.remote_enable = 1
    xdebug.remote_handler = dbgp
    xdebug.remote_host = 127.0.0.1
    xdebug.remote_log = /tmp/xdebug_remote.log
    xdebug.remote_mode = req
    xdebug.remote_port = 9005

  • I've tried with changed remote host to the IP on which website works, didn't helped.
  • Also Apache DocumentRoot was setup on /var/www while my project was somewhere else so I move project to /var/www and still nothing - but works OK on given IP above.

I'm out of ideas at this point.

P.S. I'm newbie to Linux.

1
1. Since both machines are in the same LAN, you don' need SSH forwarding, the laptop can connect to the desktop directly. 2. You're getting 404 during validation because the validation script created in I:\Projecty\website-scrapper doesn't get into /var/www, or the URL is wrong. Is website-scrapper == /var/www? 3. xdebug.remote_host = 127.0.0.1 would not work because in Xdebug, it's the remote host that initiates a connection. It should be an IP the laptop can use to connect to the laptop.Eugene Morozov
Well I've tried just now with chaning the folder, as project is in other location but earlier xdebug autodected home/user, and /var/www was added when I moved project to this location, cuz I tried what I've could. Still it didn't worked. Also I've changed IP to the one I wrote above as that's the one I use to connect laptop via Vsftpd. Also friend recommended me to change port to for example 9000, as 9005 might be used/blocked - still nothin.Volmarg Reiso
"I use to connect laptop via Vsftpd" -- To connect the laptop to the desktop, or vice-versa? Also, please check your xdebug_remote.log, usually it's very helpful in these situations.Eugene Morozov
My bad, i connect to laptop from desktop. Desktop is my working station and Laptop has all the services. I've just tried to check xdebug log but it doesn't exit.Volmarg Reiso
In Xdebug, it's the server that initiates connection, not the client, so your laptop's IP address would not work - it should be the desktop IP that the laptop can use for connecting As for the log file, please create it manually and also set 666 permissions to it, try to start a session again and then re-check the log.Eugene Morozov

1 Answers

0
votes

First of all I’m unable to pinpoint what was exactly the problem, however I’ve got few ideas looking on what I’ve changed and it suddenly started to work.

Step by step what I’ve made in order to make connection work this time.

  1. Creating new remote project
  2. Defining connection with FTP (in my case I’m connecting to my laptop with Ubuntu)

enter image description here

At this point the difference is that:

  • I’ve pointed the location manually
  • I’ve changed the Web server root URL, previously it was just IP without port etc

Next thing is Mapping. Once I’ve setup correct path in Connection tab all I had to do is:

enter image description here

  1. Selecting CLI and Path mapping

Once the connection is established, There will be list of detected remote CLI Interpreters. I’ve picked up my Laptop’s Ubuntu. Again keep an eye on Path mappings, it should be the same Root Path above.

enter image description here

Now once You press the marked button in CLI line, You will see new windows. In my case xdebug was detected.

enter image description here

Press „Open in Editor”

  1. Xdebug settings

Below are the settings I’ve got in php.ini:

zend_extension = /usr/lib/php/20170718/xdebug.so
xdebug.remote_autostart = 1
xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.remote_connect_back = 1
xdebug.remote_host = "192.168.1.100" //This is my Desktop PC IP
xdebug.remote_log = /tmp/xdebug_remote.log
xdebug.remote_mode = req
xdebug.remote_port = 9101 //This is the port under which I want xdebug to work remotely
xdebug.idekey = "PHPSTORM"

Below are settings for my Xdebug.ini file on Ubuntu (the same as above):

enter image description here

It’s worth mentioning that I had 127.0.0.1 as remote_host and Validation tool actually detected my Desktop IP this time.

  1. Validating Xdebug connection enter image description here

Keep an eye on underlined sections – this are my settings. Now go to Validate.

Upon pressing Validate, You should see settings like these below. Again be sure to pick up proper Remote connection.

enter image description here

The rest goes just with the official guide – setup Xdebug extension in browser and start listening for incoming connections.

Below are some useful links that might be helpful in case You will have some other kind of problems.