【问题标题】:Xdebug configuration with PHP fastcgi and eclipse?使用 PHP fastcgi 和 eclipse 进行 Xdebug 配置?
【发布时间】:2010-12-24 12:35:05
【问题描述】:

一年多来,我一直在将 eclipse-pdt 与 xdebug 和 apache 结合使用,没有出现任何问题。一切都完美无缺,我可以在 eclipse 中进行所有我想要的交互式调试(使用我自己的机器作为服务器)。

现在我从 apache 切换到 nginx(因此 PHP 现在不是作为 Apache 服务运行,而是作为 fast-cgi 运行),我找不到配置 eclipse 以与 xdebug 很好地配合使用的方法.我不确定问题出在 xdebug 还是 eclipse(或两者)上。

在eclipse配置中我已经将PHP配置文件的引用改为/etc/php5/cli/php.ini


尝试使用 php.ini 版本 1

带有以下php.ini文件

zend_extension=/usr/lib/php5/20060613/xdebug.so
  • 我看到 xdebug 正在运行(例如,如果我执行 var_dump(),我会得到它的 xdebug 版本,而不是普通的 PHP 版本)
  • 我无法从 Eclipse 进行交互式调试:浏览器打开并使用包含 ...?XDEBUG_SESSION_START=ECLIPSE_DBGP&KEY=... 的典型 URL 完全加载页面,但程序执行不会在断点处停止
  • 在 Eclipse 的右下角,我看到一条可疑消息:"Launching =put_the_name_of_my_project_here=: 57%""refreshing workspace" 交替出现。

尝试使用 php.ini 版本 2

如果我使用该文件的其他版本(在我切换到 nginx 之前它一直有效):

zend_extension=/usr/lib/php5/20060613/xdebug.so
xdebug.remote_enable=On
xdebug.remote_autostart=On
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_mode=req

我根本无法访问我网站的任何页面。


PS:我机器上的其他数据: - 操作系统: GNU/Linux - Ubuntu 9.10 64 位。 - PHP: 5.2.10-2ubuntu6.3 和 Suhosin-Patch 0.9.7; Zend Engine v2.2.0,版权所有 (c) 1998-2009 Zend Technologies with Xdebug v2.0.4 - Eclipse:看截图。

【问题讨论】:

    标签: php eclipse fastcgi xdebug eclipse-pdt


    【解决方案1】:

    我遇到了同样的问题并解决了。
    在文件/etc/php5/apache2/php.ini 中添加:

    [xdebug] xdebug.remote_enable=On
    xdebug.remote_autostart=off
    xdebug.remote_handler=dbgp
    xdebug.remote_host=localhost
    xdebug.remote_port=9000
    xdebug.remote_mode=req
    


    在文件/etc/php5/cli/php.ini 中添加:

    zend_extension=/usr/lib/php5/20060613/xdebug.so
    xdebug.remote_enable=On
    xdebug.remote_autostart=off
    xdebug.remote_handler=dbgp
    xdebug.remote_host=localhost
    xdebug.remote_port=9000
    xdebug.remote_mode=req
    


    重启 Apache:

    sudo service apache2 restart
    

    【讨论】:

    • @protect4you - 我现在不在我的电脑旁,所以我不能立即尝试...如果有效,稍后会发布。但是,我对这个解决方案有点困惑,因为您使用 sudo service apache2 restart 完成了您的指示,并且我 - 如问题中所述 - not 使用 apache 作为网络服务器,但 nginx...
    • 对不起。在这个解决方案中,我举的例子是 apache2。但是,如果您可以尝试使用其他网络服务:D。更改文件配置时必须重新启动 Web 服务(Apache、nginx ..)。在解决方案中,您设置需要 xdebug.remote_autostart = off。为什么要设置“xdebug.remote_autostart = off”。这是答案:如果它是“xdebug.remote_autostart = on”。这将强制 Xdebug 为在此服务器上完成的每个请求启动一个调试会话,而无需在请求中指定需要调试会话。
    【解决方案2】:

    解决方案中的问题是“xdebug.remote_autostart = on”。 如果您在文件配置中设置“xdebug.remote_autostart = on”。这将强制 Xdebug 为在此服务器上完成的每个请求启动一个调试会话,而无需在请求中指定需要一个调试会话。

    你需要改变

    "xdebug.remote_autostart = 关闭"

    然后重启网络服务。 在这个例子中是 Apache。

    您可以在这里阅读更多内容:http://doc.waterproof.fr/phpedit/debugging_profiling/configuration/debugger_with_xdebug

    祝你好运!

    【讨论】:

      【解决方案3】:

      尝试重新启动您的 php.ini。因为你有php-fastcgi,重启nginx好像不行。当我重新启动整个服务器时,更改生效。

      【讨论】:

      • 是的 php 作为服务运行,因此您可以使用以下命令重新启动它:sudo service php5-fpm restart
      【解决方案4】:

      Beau 说的是正确的(因为我是新人,所以无法投票!)。

      一般来说,在 /etc/php5/cgi/php.ini(或定位 php.ini)中添加类似

      的行
      zend_extension = /PATH_TO/xdebug.so   ## <-- NOTE the absolute path, not relational (For ex on Windows: "C:\nginx-1.9.13\php\ext\php_xdebug-2.6.0RC2-7.0-vc14-nts.dll")
      xdebug.remote_enable = on
      xdebug.remote_handler = dbgp
      xdebug.remote_host = localhost
      xdebug.remote_port = 9900        ## <-- Yours will be probly 9000 or other..
      

      完成这项工作。

      所以改变之后,

      ./php-fastcgi stop
      ./php-fastcgi start
      

      这对我有用。

      【讨论】:

      • 确保你使用 zend_extension 而不是之前的 zend_extension_ts 形式
      • 你的帖子让我寻找我需要重启的东西。我不得不运行/etc/init.d/php5-fpm restart
      【解决方案5】:

      xdebug 和 FastCGI 使用相同的默认端口 (9000)。在 php.ini 文件中更改 XDebug 的端口,如下所示:

      xdebug.remote_port=9001
      

      并更新您的 IDE 设置以使用 9001。

      【讨论】:

      • 谢谢!这解决了我在 Windows/IIS7 上的 Netbeans 中进行远程调试的问题。我从命令行使用 php -i 看到了对 php.ini 的更改,但 phpinfo() 显示了默认设置,尽管启用了 xdebug。可能是 PHP 正在加载它,但是当 Xdebug 发现它的端口正在使用而没有进行配置更改时,它正在退出。
      • 非常感谢 Effing !!!虽然我使用我的 php-fpm 和 nginx 通过套接字连接,但将默认端口更改为 9001 解决了我的问题!我猜 php-fpm 仍然占用该端口,尽管它配置为侦听套接字??
      • 是的!我一直看到tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 23266/php-fpm: mast 并想知道 php-fpm 在那里做了什么。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-06-05
      • 2019-08-15
      • 2011-08-31
      • 2011-08-23
      • 1970-01-01
      • 1970-01-01
      • 2019-03-15
      相关资源
      最近更新 更多