0

I am wondering if anyone can shed any light on the appropriate measures to take to ensure that the following set up will allow Xdebug and PhpStorm to work.

We have a LAMP stack running fine, with PHP and Xdebug 3 running on an Azure VM.

We are on a shared office network with a public IP address but no access to the firewall for the incoming line, although it's very relaxed.

We are aiming to connect our machines (x3) to debug our remote web server (the LAMP stack on the Azure VM).

We can create the SSH tunnel no problem to the web server. But debugging just doesn't work. I.e. when we fire up a page, the debugger does nothing at all.

Is anyone else running this kind of set up and confirm whether we are missing a step to ensure a successful connection.

[xdebug]
zend_extension=xdebug
xdebug.mode=debug
xdebug.client_host=127.0.0.1
xdebug.client_port=9003
xdebug.default_enable = 1
xdebug.force_display_errors = 1
xdebug.scream = 1
xdebug.force_error_reporting = NONE
xdebug.idekey = diss
xdebug.remote_enable = 1
xdebug.remote_log=/tmp/xdebug.log
xdebug.log=/var/log/xdebug.log
xdebug.remote_connect_back=0
xdebug.discover_client_host=false
12
  • 1) Yes, SSH is needed since you cannot open ports on firewall/router. 2) If you going to have multiple devs working at the same time ... you better look at DBGp Proxy (in combination with SSH tunnel I guess). 3) Do not mix Xdebug v2 and v3 config params. v3 will complain in your error log every time it sees v2 param (you do not need such useless flood). Commented Jan 6, 2021 at 14:04
  • 4) Try xdebug.start_with_request = yes -- this tells Xdebug to try and debug every single script/request without looking for "debug me" flag (cookie or ENV/GET/POST param) -- keep it until you make it work, then you can remove it to have a better control. 5) Post your Xdebug section of phpinfo() output + xdebug_info() captured in a same way as you are trying to debug it (CLI script or a web page -- important as your OS may use different php.ini for different env) Commented Jan 6, 2021 at 14:07
  • 6) Check the Xdebug log -- it will tell where it tries to connect to and what the response is. If log is empty: A) wrong path (Ubuntu virtualizes if /tmp/ is used); B) file permissions C) Xdebug is not trying to debug anything D) Something prevents that (e.g. SELinux or alike) -- rather unlikely to happen in containers, but may still affect Apache. 7) Check with telnet if your SSH tunnel is set up correctly (connect from within your VM/container back to the IDE -- PhpStorm mu be listening for connections at that stage (green phone handle icon) -- able to connect? Commented Jan 6, 2021 at 14:11
  • P.S. If you are debugging a CLI script, then you should be able to debug from many simultaneous sessions (just use different Xdebug port in IDE, IDE will pass these params when initiating CLI debug from IDE (you must have Remote PHP Interpreter configured for that). For web page debug though you cannot pass that (as it's all run on server with no control from your end) so something like DBGp Proxy has to be used to have multiple devs (as it's made for that): jetbrains.com/help/phpstorm/… Commented Jan 6, 2021 at 14:16
  • @LazyOne DBGp Proxy - I am looking at this now. Can I run it permanently in the background on the development server? Commented Jan 6, 2021 at 14:34

1 Answer 1

1

This was resolved in my case by ensuring the settings were as follows

[xdebug]
zend_extension=xdebug
xdebug.mode=debug
xdebug.client_host=127.0.0.1
xdebug.client_port=9003
xdebug.remote_log=/tmp/xdebug.log
xdebug.log=/var/log/xdebug.log

I use pydbgpproxy

    cd /opt
    sudo mkdir pydbgpproxy
    cd pydbgpproxy
    sudo wget https://github.com/Mirocow/pydbgpproxy/archive/master.zip ./
    sudo unzip master.zip ./
    sudo ln -s $(pwd)/pydbgpproxy /usr/local/bin/pydbgpproxy

Edit the pydbgpproxy

cd /opt/pydbgpproxy/pydbgpproxy-master/
sudo nano pydbgpproxy 

In line 333 replace line add=xxx with

addr = ['127.0.0.1',long(idekey)]

Start pydbgproxy on the server

nohup sudo /opt/pydbgpproxy/pydbgpproxy-master/pydbgpproxy -i 127.0.0.1:1001-d 127.0.0.1:1003 &

Create an SSH connection to the development server with an SSH tunnel:

Source Port: 1234 **This must match your unique IDE key set below.**
Destination: 127.0.0.1:1003

Change your debugger port to 9003 in PhpStorm File > Settings > Languages & Frameworks > PHP > Debug

Debug Port: 1003

Change your proxy settings to: File > Settings > Languages & Frameworks > PHP > Debug > DBGp Proxy

IDE Key: 1234 **Unique IDE Key - This must be unique to you and must be numerical**
Host: 0.0.0.0 **External IP Address of the Dev Server**
Port: 1001

Make sure your xdebug helper extension is set to use key 1234

What you set as your IDE key above, must be unique

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.