Search code examples
phplinuxphpstormxdebug

Xdebug with PhpStorm on Ubuntu


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

Solution

  • 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