Remote PHP Debugging with Netbeans and XDebug

前端 未结 6 774
醉酒成梦
醉酒成梦 2020-12-31 06:35

I\'m trying to use XDebug in the following scenario

  • Physical Host on Windows 7, with Netbeans 7.1.1
  • Virtual guest on Ubuntu, with Apache server and PH
相关标签:
6条回答
  • 2020-12-31 06:58

    In know this is old but a good reminder. Make sure if you are using nat in virtualbox that you set port forwarding on the xdebug port back to the local machine typically 9000 by default.

    0 讨论(0)
  • 2020-12-31 07:02

    Debugging remotely with Linux + Apache + PHP + xdebug + NetBeans (SFTP)

    I've got the following setup and it works.

    Host PC (client)

    • Linux Debian Jessie **
    • NetBeans version 8.0.2
    • NetBeans has a project created as "PHP Application from Remote Server", that has to be debugged
    • NetBeans connects to Remote Server using SFTP
    • IP (for example): 192.168.0.2

    ** I am aware that the OP question mentions Windows, but regarding that the main setup to solve this should be made on the VM, I hope this helps somebody anyway.

    Guest PC (server) / Virtual Machine

    • Linux Debian Jessie
    • Apache
    • PHP 5.6
    • xdebug 2.2.5
    • IP (for example): 192.168.0.1

    The following steps should be made on the "Guest PC (server) / Virtual Machine"

    1. install xdebug sudo apt-get install php5-xdebug
    2. edit /etc/php5/apache2/php.ini,

    add these lines right before the [Date] AND change xdebug.remote_host to reflect your "Host PC (client)" IP:

    [debug]
    ; Remote settings
    xdebug.remote_autostart=off
    xdebug.remote_enable=on
    xdebug.remote_handler=dbgp
    xdebug.remote_mode=req
    xdebug.remote_host=192.168.0.2
    xdebug.remote_port=9000
    
    1. restart apache sudo service apache2 restart

    Reference

    How to configure XDebug - Remote Debuging http://wiki.netbeans.org/HowToConfigureXDebug#Remote_Debuging

    you need to have correctly configured property xdebug_remote.host on remote machine. The IP address of local machine has to be defined in this property. For example, you want to debug your source code on remote machine 192.168.0.1 using Netbeans installed on 192.168.0.2. You need to change xdebug.remote_host on 192.168.0.1 to xdebug.remote_host=192.168.0.2. If doesn't work verify you have port configured in xdebug.remote_port open on both machines.

    0 讨论(0)
  • 2020-12-31 07:02

    If all seems to be correct but you still get "Waiting For Connection" from inside netbeans you should try in your php.ini settings

    xdebug.remote_connect_back=on
    

    as it allows connection from ANY ip or look at a lot more info on the issue http://www.devside.net/wamp-server/netbeans-waiting-for-connection-netbeans-xdebug-issue

    0 讨论(0)
  • 2020-12-31 07:03

    Go through the below document for remote debugging using NetBeans. Very helpful. http://stuporglue.org/setting-up-xdebug-with-netbeans-on-windows-with-a-remote-apache-server/

    0 讨论(0)
  • 2020-12-31 07:15

    Another option is to have the VM configured to speak to its own localhost:9000 (default for xdebug) and then ssh in from host to VM and establish a port tunnel for that port back to the host machine. Then your host machine debugger simply connects to localhost:9000 and everything should work exactly as if they were running on the same machine.

    See: Multiple users XDebug and PHP Debugging

    0 讨论(0)
  • 2020-12-31 07:20

    Sorry, i can't comment anymore. @David @JamesB41: I've been looking for this too. My setup is a Windows 7 host with NetBeans 7.1, and an Ubuntu VM in VirtualBox. I have the NetBeans project set up as a remote project, uploading and downloading using SFTP.

    The following setup works for me, just use your host's IP as remote_host, and make sure the VM can see it.

    xdebug.remote_enable=1
    xdebug.remote_handler=dbgp
    xdebug.remote_host=10.217.165.193
    xdebug.remote_port=9000
    xdebug.remote_log="/tmp/log/xdebug.log"
    

    NetBeans will stop at the entry point breakpoint (if you have the option set in PHP->Debugging). But, it won't stop on NetBeans-created breakpoints, because its running off the VM's files. You can use xdebug_break() though, and it will show stack and variables. It will stop at NetBeans breakpoints and highlight if you map the folders correctly in project config > Run Config > Advanced. Awesome. I am complete.

    (The connect_back config didn't seem to help, possibly because $_SERVER['REMOTE_ADDR'] isn't populated.)

    0 讨论(0)
提交回复
热议问题