使用 PHP fastcgi 和 eclipse 进行 Xdebug 配置?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1868568/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xdebug configuration with PHP fastcgi and eclipse?
提问by mac
I have been using eclipse-pdt in conjunction with xdebug and apache without problems, for over one year. Things worked flawlessly and I could do all the interactive debugging I wanted from within eclipse (using my own machine as a server).
一年多以来,我一直将 eclipse-pdt 与 xdebug 和 apache 结合使用,没有任何问题。事情完美无缺,我可以在 eclipse 中进行所有我想要的交互式调试(使用我自己的机器作为服务器)。
Now I switched from apache to nginx (and therefore PHP runs now not as an Apache service but as fast-cgi)and I can't find a way to configure eclipse to work nicely with xdebug. I am neither sure if the problem is with xdebug or with eclipse (or both) to be sure.
现在我从 apache 切换到 nginx(因此 PHP 现在不是作为 Apache 服务运行,而是作为 fast-cgi 运行)并且我找不到一种方法来配置 eclipse 以与 xdebug 很好地工作。我不确定问题是与 xdebug 还是与 eclipse(或两者)有关。
In the eclipse configuration I already changed the reference to the PHP configuration file to /etc/php5/cli/php.ini
.
在 eclipse 配置中,我已经将 PHP 配置文件的引用更改为/etc/php5/cli/php.ini
.
Attempts with php.ini version 1
尝试使用 php.ini 版本 1
With the following php.ini
file
使用以下php.ini
文件
zend_extension=/usr/lib/php5/20060613/xdebug.so
- I see that xdebug is working (for example if I do a
var_dump()
I get the xdebug version of it, not the plain PHP one) - I can't have the interactive debugging from eclipse: the browser opens up and loads the page completely with the typical URL containing
...?XDEBUG_SESSION_START=ECLIPSE_DBGP&KEY=...
, but the program execution does not stop at breakpoints - In the bottom-right corner of eclipse I see a suspicious message: "Launching =put_the_name_of_my_project_here=: 57%"that alternates with the "refreshing workspace"one.
- 我看到 xdebug 正在工作(例如,如果我做了一个
var_dump()
我得到它的 xdebug 版本,而不是普通的 PHP 版本) - 我无法从 Eclipse 进行交互式调试:浏览器打开并使用包含 的典型 URL 完全加载页面
...?XDEBUG_SESSION_START=ECLIPSE_DBGP&KEY=...
,但程序执行不会在断点处停止 - 在 eclipse 的右下角,我看到一条可疑消息:“Launching =put_the_name_of_my_project_here=: 57%”与“刷新工作区”交替出现。
Attempts with php.ini version 2
尝试使用 php.ini 版本 2
If I use this other version of the file (which is what it worked until I switched to nginx):
如果我使用该文件的另一个版本(在我切换到 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
I can't access any page of my sites at all.
我根本无法访问我网站的任何页面。
PS: Additional data on my machine: - OS:GNU/Linux - Ubuntu 9.10 64 bit. - PHP:5.2.10-2ubuntu6.3 with Suhosin-Patch 0.9.7; Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies with Xdebug v2.0.4 - Eclipse:see screenshot.
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:见截图。
采纳答案by valk
What Beau said is correct (couldn't vote since I'm new!).
Beau 说的是正确的(因为我是新人,所以无法投票!)。
Generally, addging to /etc/php5/cgi/php.ini (or locate php.ini) the lines like
通常,添加到 /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..
does the job.
做这项工作。
So after the change,
所以改变之后,
./php-fastcgi stop
./php-fastcgi start
This worked for me.
这对我有用。
回答by Maxence
xdebug and FastCGI use the same default port (9000). Change the port of XDebug in your php.ini file like this:
xdebug 和 FastCGI 使用相同的默认端口 (9000)。在 php.ini 文件中更改 XDebug 的端口,如下所示:
xdebug.remote_port=9001
and update your IDE settings to use 9001.
并更新您的 IDE 设置以使用 9001。
回答by Beau
Try restarting your php. Because you have php-fastcgi, restarting nginx doesn't seem to do it. When I rebooted my whole server the change took effect.
尝试重新启动您的 php。因为你有 php-fastcgi,重启 nginx 好像不行。当我重新启动整个服务器时,更改生效。
回答by protect4you
I had the same problem and solved it.
In file /etc/php5/apache2/php.ini
add:
我遇到了同样的问题并解决了它。
在文件中/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
In file /etc/php5/cli/php.ini
add:
在文件中/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
Restart Apache:
重启阿帕奇:
sudo service apache2 restart
回答by protect4you
Problem in solution is "xdebug.remote_autostart = on". If you set in file config "xdebug.remote_autostart = on". This will force Xdebug to start a debug session for every request that is done on this server, without having to specify in the request that a debug session is wanted.
解决方案中的问题是“ xdebug.remote_autostart = on”。如果您在文件配置中设置“ xdebug.remote_autostart = on”。这将强制 Xdebug 为在此服务器上完成的每个请求启动调试会话,而无需在请求中指定需要调试会话。
You need change
你需要改变
"xdebug.remote_autostart = off"
" xdebug.remote_autostart = off"
And restart web service. In this example is Apache.
并重新启动网络服务。在这个例子中是 Apache。
You can read more here: http://doc.waterproof.fr/phpedit/debugging_profiling/configuration/debugger_with_xdebug
您可以在此处阅读更多信息:http: //doc.waterproof.fr/phpedit/debugging_profiling/configuration/debugger_with_xdebug
GoodLuck!
祝你好运!