nginx php-fpm xdebug netbeans只能启动一个调试会话 [英] nginx php-fpm xdebug netbeans can start only one debug session

查看:123
本文介绍了nginx php-fpm xdebug netbeans只能启动一个调试会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

过去,我很乐意使用 apache + mod_php + xdebug + netbeans开发我的网站(服务器是运行Debian Squeeze的本地计算机),xdebug的工作原理与预期一致,调试会话可以在需要时随时启动和停止.但是,当我移到 nginx + php_fpm + xdebug + netbeans时,调试遇到了一些问题.

In the past, I've used apache+mod_php+xdebug+netbeans for development my website (server is my local machine, running Debian Squeeze), with pleasure - xdebug worked just as expected, debug sessions could be started and stopped any time, when I need it. But, when I moved to nginx+php_fpm+xdebug+netbeans I've experienced some problems with debugging.

  1. 我的调试会话可能很长(远远超过30秒),而且看来nginx等不了那么久,它显示了"504网关超时错误" .我已经尝试了很多建议来解决此问题,但是没有运气.但是,对我来说这不是很重要,因为调试会话本身仍在继续运行,这只是一件令人不舒服的事情.
  2. 我的调试会话只能运行一次,因此,如果我停止它,然后尝试再次启动调试,netbeans将无法接受来自xdebug的连接(它写为"Waiting for xdebug connection",并且永远存在).重新启动netbeans之后,调试会话可以再次正常启动.
  3. 在某些情况下,我无法理解,调试是为所有php脚本打开",并阻止其他任何脚本运行.例如,我在网站的 http://mysite.local/index.php 上启动调试会话,并开始工作用它.一段时间后,我注意到我的管理员(放在intranet.local/adminer.php上)没有运行,浏览器尝试加载页面一段时间,然后显示"504网关超时错误". .如果出现这种情况,我可以在netbeans中停止xdebug调试会话,然后所有其他脚本开始正常运行.
  1. My debug session could be very long (much more than 30 seconds) and it seems, that nginx couldn't wait so long, it shows "504 Gateway timeout error". I've tried lots of recommendations for solve this, but no luck. Though, it is not a very important for me, because of debugging session itself continues to run, and it's just a little uncomfortable thing.
  2. My debug session could be run only once, so, if I stop it, and try to launch debugging again, netbeans couldn't accept connection from xdebug (it writes "Waiting for xdebug connection" and it is forever). After restart of netbeans the debug session could be started again normally.
  3. In come cases, that I couldn't understand, the debugging is "turning on for all php scripts" and prevent's any other scripts to run. For example, I start debug session on my website's http://mysite.local/index.php and working with it. After some time, I noticed, that my adminer (placed on intranet.local/adminer.php) doesnt run, the browser tries to load page for some time, and than shows "504 Gateway timeout error". If I see this behavior, I could just stop xdebug debug session in netbeans, and all other scripts starting to operate normally.

现在,当我写这个问题时,我进行了一些调查,发现,如果我启动调试会话几秒钟,则在此之后将其停止,然后再次启动-它可以正常启动.经过一段时间的主动调试后,似乎出现了问题.

Now, when I writing this question, I made some investigations, and found, that, if I start debug session for some seconds, after that stop it, and start again - it starts normally. It seems like the problem appears after some time of active debugging.

我的系统和应用程序: Debian挤压:2.6.32-5-686 Nginx:1.4.1(来自dotdeb存储库) php5-fpm:5.3.26-1〜d(来自dotdeb仓库) php5-xdebug:5.3.26-1〜d(来自dotdeb仓库) netbeans:7.3

My system and apps: Debian squeeze:2.6.32-5-686 Nginx: 1.4.1 (from dotdeb repository) php5-fpm: 5.3.26-1~d (from dotdeb repository) php5-xdebug: 5.3.26-1~d (from dotdeb repository) netbeans: 7.3

我的配置:

  1. nginx基本配置: https://gist.github.com/MihanEntalpo/6229801
  2. nginx网站配置文件: https://gist.github.com/MihanEntalpo/6229781
  3. fastcgi_params文件: https://gist.github.com/MihanEntalpo/d93fd4105573e1eda56f
  4. php-fpm池配置文件: https://gist.github.com/MihanEntalpo/6229820
  5. php-fpm xdebug配置文件: https://gist.github.com/MihanEntalpo/6229836
  6. netbeans:选项,与apache服务器相同:
    • 第一行中断= OFF
    • 弹出窗口中的评估=开启
    • 显示请求的URL = ON
    • 端口= 9000
  1. nginx base config: https://gist.github.com/MihanEntalpo/6229801
  2. nginx website config file: https://gist.github.com/MihanEntalpo/6229781
  3. fastcgi_params file: https://gist.github.com/MihanEntalpo/d93fd4105573e1eda56f
  4. php-fpm pool config file: https://gist.github.com/MihanEntalpo/6229820
  5. php-fpm xdebug config file: https://gist.github.com/MihanEntalpo/6229836
  6. netbeans: options, that was just the same with apache server:
    • Break on first line = OFF
    • Evalution in popup window = ON
    • Show requesting URL's = ON
    • Port = 9000

记录nginx的错误日志文件中的内容,因为它无法等待被问题3锁定的脚本或其他脚本被调试,

Record in nginx's error log file, when it cannot wait for script being debugged, or other script, locked by the problem #3, mentioned early:

2013/08/14 14:40:16 [错误] 4822#0:* 111上游超时(110:连接超时),同时从上游读取响应头,客户端:192.168.100.1,服务器:intranet.local ,请求:"GET/adminer.php?username=root&db=devel&table=user HTTP/1.1",上游:"fastcgi://127.0.0.1:9999",主机:"intranet.local",引荐来源网址: " https://intranet.local/adminer.php?username = root& db =开发"

2013/08/14 14:40:16 [error] 4822#0: *111 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 192.168.100.1, server: intranet.local, request: "GET /adminer.php?username=root&db=devel&table=user HTTP/1.1", upstream: "fastcgi://127.0.0.1:9999", host: "intranet.local", referrer: "https://intranet.local/adminer.php?username=root&db=devel"

php-fpm的日志不包含任何错误消息...

php-fpm's logs doesn't contains ANY error messages...

我不想让任何人打扰我的问题,而总是尝试自己解决.但是在这种情况下,我要和这个比赛争取几个月的运气,但是没有运气... 如果有人遇到此问题,或者具有可与nginx + php-fpm + xdebug + netbeans配合使用的有效配置-请帮助我:)

I don't like to disturb anyone with my problems, and always trying to solve it by myself. But in this case, I'm fighting with this ones for some MONTHS without luck... If anyone faced this problems, or have working config for using with nginx+php-fpm+xdebug+netbeans - please help me :)

推荐答案

谢谢大家,每个尝试朝我的方向思考的人. 我已经成功解决了.

Thank you, everyone who tried to think in the direction of my problem. I've solve it successfully.

  1. 第一个问题(带有504错误)可以通过nginx选项 fastcgi_read_timeout 解决,例如,它可能是fastcgi_read_timeout 600;,用于告知nginx应该等待600秒.应该将其放置在主机的配置文件中,或放置在/etc/nginx/fastcgi_params(在Debian中)
  2. 第二个问题是由我的xdebug.conf中的选项引起的:xdebug.remote_autostart=1;,它应该是xdebug.remote_autostart=0;.我不了解此选项的真正含义,但是它可以执行以下操作:任何php脚本都会自动尝试连接到调试器(在我的情况下为netbeans).因此,在某些情况下,netbeans失去了连接,当我按开始调试"时,它不知道应该打开新的连接,并永远等待xdebug客户端.现在,使用上述选项,我可以在需要时随时启动和停止调试.
  3. 第三个问题与第二个问题具有相同的来源.在我的服务器上运行的所有其他脚本都试图连接到netbeans,但是失去连接却毫无意义.
  1. First problem (with 504 error) could be solved by nginx option fastcgi_read_timeout, for example, it could be fastcgi_read_timeout 600; for tell nginx that it should wait for 600 seconds. It should be placed to host's config file, or to /etc/nginx/fastcgi_params (in Debian)
  2. Second problem was caused by option in my xdebug.conf: xdebug.remote_autostart=1;, it should be xdebug.remote_autostart=0;. I doesn't understand the real meaning of this option, but it does following: Any php script automatically trying to connect to debugger (netbeans in my case). So, in some case, netbeans loses a connection, and when I press "Start debugging", it doesn't know, that new connection should be opened, and waiting for xdebug client forever. Now, with the mentioned option, I can start and stop debugging any time when I need it.
  3. Third problem had the same source, as the second one. All others scripts, running on my server have tried to connect to netbeans, but with lost connection it was senseless.

无论如何,我希望这对希望解决类似问题的人有所帮助. StackOverflow迫使我明确描述自己的问题,从而对我有所帮助,在此过程中,我对尝试的方法有了新的认识.

Anyway, I hope this would help someone, who want to solve similar problems. StackOverflow helped me by forcing me to definitely describe my problem, and in this process I've gained new ideas on what to try.

这篇关于nginx php-fpm xdebug netbeans只能启动一个调试会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆