Jump to content

Xdebug on remote server; Netbeans local


threehappypenguins

Recommended Posts

I have Netbeans installed on a local Ubuntu Desktop and have set up Netbeans "Php Application from Remote Server". The remote server is a headless ubuntu server in an Oracle compute instance. Everything downloaded fine with an sftp connection.

I tried to follow these instructions (and these updated ones) but I'm still getting "Waiting for Connection" in Netbeans. For example, on the remote, headless server, in /etc/php/7.4/cli/conf.d/20-xdebug.ini (which is also symlinked to /etc/php/7.4/mods-available/xdebug.ini):

[xdebug]
zend_extension=/usr/lib/php/20190902/xdebug.so
xdebug.remote_autostart=off
xdebug.remote_handler=dbgp
xdebug.mode=debug
xdebug.client_host=localhost
xdebug.client_port=9003
xdebug.remote_mode=req
output_buffering=off
xdebug.remote_log="/var/log/xdebug.log"

And at the end of /etc/php/7.4/cli/php.ini:

[xdebug]
zend_extension=/usr/lib/php/20190902/xdebug.so
xdebug.remote_autostart=off
xdebug.remote_handler=dbgp
xdebug.mode=debug
xdebug.client_host=localhost
xdebug.client_port=9003
xdebug.remote_mode=req
output_buffering=off
xdebug.remote_log="/var/log/xdebug.log"

I then restart php and nginx (I have nginx, not Apache):

sudo systemctl restart php7.4-fpm
sudo systemctl restart nginx

On my laptop in terminal (which has Ubuntu Desktop), I port forward with the following:

ssh -R 9003:localhost:9003 -i ~/.ssh/rsa_key -f -N user@remote-server.com

To check if remote port forwarding is working, in my remote server:

netstat -a -n | grep 9003

It correctly shows:

tcp        0      0 127.0.0.1:9003          0.0.0.0:*               LISTEN     
tcp6       0      0 ::1:9003                :::*                    LISTEN

But then I go to start debugging in Netbeans, and I get the dreaded "Waiting for Connection." I'm not sure what else to do. For further information, on my remote server, I did:

sudo php -i

and pasted the contents into the Xdebug Wizard. I did it again just now, and here are the results:

Summary

  • Xdebug installed: 3.1.6
  • Server API: Command Line Interface
  • Windows: no
  • Zend Server: no
  • PHP Version: 7.4.3
  • Zend API nr: 320190902
  • PHP API nr: 20190902
  • Debug Build: no
  • Thread Safe Build: no
  • OPcache Loaded: yes
  • Configuration File Path: /etc/php/7.4/cli
  • Configuration File: /etc/php/7.4/cli/php.ini
  • Extra Configuration Files Path: /etc/php/7.4/cli/conf.d

Extra Configuration Files:
/etc/php/7.4/cli/conf.d/10-mysqlnd.ini
/etc/php/7.4/cli/conf.d/10-opcache.ini
/etc/php/7.4/cli/conf.d/10-pdo.ini
/etc/php/7.4/cli/conf.d/15-xml.ini
/etc/php/7.4/cli/conf.d/20-bz2.ini
/etc/php/7.4/cli/conf.d/20-calendar.ini
/etc/php/7.4/cli/conf.d/20-ctype.ini
/etc/php/7.4/cli/conf.d/20-curl.ini
/etc/php/7.4/cli/conf.d/20-dom.ini
/etc/php/7.4/cli/conf.d/20-exif.ini
/etc/php/7.4/cli/conf.d/20-ffi.ini
/etc/php/7.4/cli/conf.d/20-fileinfo.ini
/etc/php/7.4/cli/conf.d/20-ftp.ini
/etc/php/7.4/cli/conf.d/20-gd.ini
/etc/php/7.4/cli/conf.d/20-gettext.ini
/etc/php/7.4/cli/conf.d/20-iconv.ini
/etc/php/7.4/cli/conf.d/20-intl.ini
/etc/php/7.4/cli/conf.d/20-json.ini
/etc/php/7.4/cli/conf.d/20-mbstring.ini
/etc/php/7.4/cli/conf.d/20-mysqli.ini
/etc/php/7.4/cli/conf.d/20-pdo_mysql.ini
/etc/php/7.4/cli/conf.d/20-phar.ini
/etc/php/7.4/cli/conf.d/20-posix.ini
/etc/php/7.4/cli/conf.d/20-readline.ini
/etc/php/7.4/cli/conf.d/20-shmop.ini
/etc/php/7.4/cli/conf.d/20-simplexml.ini
/etc/php/7.4/cli/conf.d/20-soap.ini
/etc/php/7.4/cli/conf.d/20-sockets.ini
/etc/php/7.4/cli/conf.d/20-sysvmsg.ini
/etc/php/7.4/cli/conf.d/20-sysvsem.ini
/etc/php/7.4/cli/conf.d/20-sysvshm.ini
/etc/php/7.4/cli/conf.d/20-tokenizer.ini
/etc/php/7.4/cli/conf.d/20-xdebug.ini
/etc/php/7.4/cli/conf.d/20-xmlreader.ini
/etc/php/7.4/cli/conf.d/20-xmlrpc.ini
/etc/php/7.4/cli/conf.d/20-xmlwriter.ini
/etc/php/7.4/cli/conf.d/20-xsl.ini
/etc/php/7.4/cli/conf.d/20-zip.ini

  • Extensions directory: /usr/lib/php/20190902

You're already running the latest Xdebug version

But here are the instructions anyway:

  1. Download xdebug-3.1.6.tgz
  2. Install the pre-requisites for compiling PHP extensions.
    On your Ubuntu system, install them with: apt-get install php-dev autoconf automake
  3. Unpack the downloaded file with tar -xvzf xdebug-3.1.6.tgz
  4. Run: cd xdebug-3.1.6
  5. Run: phpize (See the FAQ if you don't have phpize).
    As part of its output it should show:
    Configuring for:
    ...
    Zend Module Api No:      20190902
    Zend Extension Api No:   320190902
  6. Run: ./configure

  7. Run: make

  8. Run: cp modules/xdebug.so /usr/lib/php/20190902

  9. Update /etc/php/7.4/cli/conf.d/20-xdebug.ini to have the line:
    zend_extension = xdebug

  10. Please also update php.ini files in adjacent directories, as your system seems to be configured with a separate php.ini file for the web server and command line.

Enabling Features

Now Xdebug is installed, you can enable its features. Please refer to the dedicated sections in the documentation about information on how to enable and configure these Xdebug features. Where these sections refer to php.ini or similar, please remember to use /etc/php/7.4/cli/conf.d/20-xdebug.ini:

  • Development Helpers — help you get better error messages and obtain better information from PHP's built-in functions.
  • Step Debugging — allows you to interactively walk through your code to debug control flow and examine data structures.
  • Profiling — allows you to find bottlenecks in your script and visualize those with an external tool.
Link to comment
Share on other sites

Rather than guess at what docs are correct, use the official ones. Like that Step Debugging link, which tells you:

1. Set xdebug.mode=debug
2. Since you're a "complex setup" with a remote setup and SSH tunneling, set xdebug.client_host=localhost and client_port=9003 (which your SSH session will forward, provided you have that running at all times).
3. To use triggered debugging for a web application, either (a) set ?XDEBUG_SESSION_START=session name in the URL of the one page you want, (b) an XDEBUG_SESSION cookie, or (c) call xdebug_break() in code.

You can also look at the All Settings page to discover that settings like remote_autostart, remote_handler, and remote_mode don't exist anymore.

Link to comment
Share on other sites

3 hours ago, requinix said:

1. Set xdebug.mode=debug

Already had it in there, in both files.

Quote

2. Since you're a "complex setup" with a remote setup and SSH tunneling, set xdebug.client_host=localhost and client_port=9003 (which your SSH session will forward, provided you have that running at all times).

Also had them in both files.

Quote


3. To use triggered debugging for a web application, either (a) set ?XDEBUG_SESSION_START=session name in the URL of the one page you want, (b) an XDEBUG_SESSION cookie, or (c) call xdebug_break() in code..

It doesn't help me to connect.

Quote

You can also look at the All Settings page to discover that settings like remote_autostart, remote_handler, and remote_mode don't exist anymore.

I went ahead and erased remote_autostart, remote_handler, and remote_mode in both files. I still can't connect.

Any other ideas on why I can't connect?

Link to comment
Share on other sites

I *finally* got somewhere! I did, in fact, need to re-enable the browser opening (Run > Set Project Configuration > Customize > Advanced > Default) so that the browser opens with "?XDEBUG_SESSION_START=session name" at the end of the address. I previously had "Do Not Open Web Browser" because of these instructions. Once I re-enabled the Web Browser, it worked and connected. When I had attempted those instructions before (and didn't disable the web browser thing), I had configurations for xdebug 2, but I needed xdebug 3. I had changed to xdebug 3, but it didn't work until I enabled the web browser opening again. Now, upon the web browser opening, I'm getting "504 Gateway Time-out." But at least I can connect remotely with xdebug now!

Link to comment
Share on other sites

More additional changes. I do not need to add anything to the end of /etc/php/7.4/cli/php.ini either. Also, if I add xdebug.log=/var/log/xdebug.log to my 20-xdebug.ini file, then it starts recording a log (I had the wrong syntax; needed xdebug 3). It shows:

[1490345] [Config] INFO: Trigger value for 'XDEBUG_TRIGGER' not found, falling back to 'XDEBUG_SESSION'
[1490345] [Config] INFO: Trigger value for 'XDEBUG_SESSION' not found, so not activating

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.