Remote PHP Debugging with Netbeans and XDebug

前端 未结 6 815
醉酒成梦
醉酒成梦 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 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.

提交回复
热议问题