Home  >  Article  >  php教程  >  Eclipse+PDT+Xdebug 远程调试Linux主机上的apache+php工程

Eclipse+PDT+Xdebug 远程调试Linux主机上的apache+php工程

WBOY
WBOYOriginal
2016-06-13 10:53:071372browse

本文描述远程调试Linux主机上的apache+php工程,各端需要的工具示意图如下:

CLIENT(windows, 10.239.54.24)-----------------------------------------------------------------SERVER(ubuntu 10.04, 10.239.54.115)

browser with xdebug plugin                                                                                                       xdebug

eclipse with PDT


环境安装:

        1. Eclipse juno 4.2

        2. PDT (Eclipse->Help->Install New Software(Juno - http://download.eclipse.org/releases/juno)->Programming Languages->PHP Development Tools(PDT) SDK feature)

        3. Xdebug

               CLIENT端浏览器插件安装
               SERVER端xdebug安装:    sudo apt-get install php5-xdebug

              

环境配置:

        1. SERVER端:

                           确保 /etc/php5/apache2/php.ini 包含下面的配置

                                     [Xdebug]
                                     zend_extension="/usr/lib/php5/20090626+lfs/xdebug.so"
                                     xdebug.remote_enable=On
                                     xdebug.remote_host=$clientIP 如 "10.239.54.24"
                                     xdebug.remote_port=9000
                                     xdebug.remote_handler="dbgp"
                                    等。。。

        2. CLIETNT端:

                             1) Eclipse配置如下:

                                 Eclipse -> Window->Preferences->General->Web Browser->Use external web browser->Chrome

                                 Eclipse -> Window->Preferences->PHP->Debug->PHP Debuger->Xdebug(默认是Zend Debugger)

                             2) 工程Debug配置如下:

                                  假如工程test_debug的首页为index.php

                                  使用Eclipse打开index.php,在菜单栏 Run->Debug Configurations,会弹出一个具有Server、Debugger的框。

                                  server选项卡->New, 填入Name、Base URL (如http://10.239.54.115)、Local Web Root (browse到test_debug的工程目录),然后finish

                                  回到server选项卡,有个URL的信息,对应SERVER上的该工程的index.php,默认勾选“Auto Generate”,URL值可能为 http://10.239.54.115 +                                                         /test_debug/index.php,如果不对,将其修改正确。这一步如果不对,debug的时候,chrome会报出找不到页面之类的错误。如果要加参数,在URL中加                                       上。

经过以上过程,就可以设置断点,点击F11, chrome浏览器会自动打开,和你的eclipse配置配合,那么,开始debug 吧!

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn