在 Vagrant 中使用 XDEBUG

Using XDEBUG in Vagrant

我当前的 XDEBUG 设置是 -

xdebug

xdebug support  enabled
Version 2.3.2
IDE Key 1
Supported protocols Revision
DBGp - Common DeBuGger Protocol $Revision: 1.145 $
Directive   Local Value Master Value
xdebug.auto_trace   Off Off
xdebug.cli_color    0   0
xdebug.collect_assignments  Off Off
xdebug.collect_includes On  On
xdebug.collect_params   0   0
xdebug.collect_return   Off Off
xdebug.collect_vars Off Off
xdebug.coverage_enable  On  On
xdebug.default_enable   On  On
xdebug.dump.COOKIE  no value    no value
xdebug.dump.ENV no value    no value
xdebug.dump.FILES   no value    no value
xdebug.dump.GET no value    no value
xdebug.dump.POST    no value    no value
xdebug.dump.REQUEST no value    no value
xdebug.dump.SERVER  no value    no value
xdebug.dump.SESSION no value    no value
xdebug.dump_globals On  On
xdebug.dump_once    On  On
xdebug.dump_undefined   Off Off
xdebug.extended_info    On  On
xdebug.file_link_format no value    no value
xdebug.force_display_errors Off Off
xdebug.force_error_reporting    0   0
xdebug.halt_level   0   0
xdebug.idekey   vagrant vagrant
xdebug.max_nesting_level    256 256
xdebug.max_stack_frames -1  -1
xdebug.overload_var_dump    On  On
xdebug.profiler_aggregate   Off Off
xdebug.profiler_append  Off Off
xdebug.profiler_enable  Off Off
xdebug.profiler_enable_trigger  Off Off
xdebug.profiler_enable_trigger_value    no value    no value
xdebug.profiler_output_dir  /tmp    /tmp
xdebug.profiler_output_name cachegrind.out.%p   cachegrind.out.%p
xdebug.remote_autostart On  On
xdebug.remote_connect_back  On  On
xdebug.remote_cookie_expire_time    3600    3600
xdebug.remote_enable    On  On
xdebug.remote_handler   dbgp    dbgp
xdebug.remote_host  10.0.2.2    10.0.2.2
xdebug.remote_log   no value    no value
xdebug.remote_mode  req req
xdebug.remote_port  9000    9000
xdebug.scream   Off Off
xdebug.show_exception_trace Off Off
xdebug.show_local_vars  Off Off
xdebug.show_mem_delta   Off Off
xdebug.trace_enable_trigger Off Off
xdebug.trace_enable_trigger_value   no value    no value
xdebug.trace_format 0   0
xdebug.trace_options    0   0
xdebug.trace_output_dir /tmp    /tmp
xdebug.trace_output_name    trace.%c    trace.%c
xdebug.var_display_max_children 128 128
xdebug.var_display_max_data 512 512
xdebug.var_display_max_depth    3   3

我运行 XDEBUG、NGINX 和PHP 在一个流浪者盒子下。我正在使用 VIM vagrant 插件。我可以通过 SSH 进入 vagrant box 并在端口 9000 上创建一个到我主机的 telnet 连接,而 运行 vim vagrant 插件它会挂起插件直到我关闭 telnet,所以我知道通信是可能。

但是,当我在传递 localbox/phpinfo.php?XDEBUG_SESSION_START=1

时尝试连接到 URL

更新 - 我现在可以使用 VIM 的 Vdebug 进行连接。但是,该页面在返回错误 502 BAD 网关之前挂起了几秒钟。 Nginx 将错误报告为

[error] 20913#0: *3 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 192.168.50.1, server: localhost, request: "GET /phpinfo.php?XDEBUG_SESSION_START=1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "cpd.local"

有谁知道如何通过对等调试重置连接?

检查是否有任何端口与php-fpm 冲突。如果你是运行 php-fpm,这个默认监听9000端口

我不得不更改 xdebug 以在 运行 nginx 和 php-fpm 的流浪机器上监听不同的端口(例如 9001)以避免端口冲突。

您必须重新启动 nginx 和 php-fpm。

您实际已连接。 Nginx 正在关闭该进程,因为它认为它已挂起。

fastcgi_read_timeout300;

将值设置得更高,以便有更好的调试时间。 inn vdebug 你需要添加一个path map