XDEBUG总是监听新请求,并阻止加载网页,以防我不监听

人气:216 发布:2022-10-16 标签: php xdebug php-7 php-7.4 xdebug-3

问题描述

我在我的新工作场所有一个奇怪的设置,它的工作方式如下:如果我运行了PhpStorm,并且&开始侦听PHP调试连接,那么我的本地PHP应用程序工作得很好。一旦我完全关闭PhpStorm(并因此停止侦听PHP调试连接),我的网页就不会加载(nginx在一分钟后超时)。

这是我的xdebug.ini配置:

xdebug.mode=debug 
xdebug.start_with_request=no 
xdebug.discover_client_host=no
xdebug.client_host=127.0.0.1 
xdebug.log_level=0 
;xdebug.log=/var/log/xdebug.log

以下是php -i | grep -i xdebug的输出:

/etc/php/7.4/cli/conf.d/20-xdebug.ini,
    with Xdebug v3.1.1, Copyright (c) 2002-2021, by Derick Rethans
xdebug
Support Xdebug on Patreon, GitHub, or as a business: https://xdebug.org/support
             Enabled Features (through 'xdebug.mode' setting)
xdebug.auto_trace => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3)
xdebug.cli_color => 0 => 0
xdebug.client_discovery_header => no value => no value
xdebug.client_host => 127.0.0.1 => 127.0.0.1
xdebug.client_port => 9003 => 9003
xdebug.cloud_id => no value => no value
xdebug.collect_assignments => Off => Off
xdebug.collect_includes => (setting removed in Xdebug 3) => (setting removed in Xdebug 3)
xdebug.collect_params => (setting removed in Xdebug 3) => (setting removed in Xdebug 3)
xdebug.collect_return => Off => Off
xdebug.collect_vars => (setting removed in Xdebug 3) => (setting removed in Xdebug 3)
xdebug.connect_timeout_ms => 200 => 200
xdebug.coverage_enable => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3)
xdebug.default_enable => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3)
xdebug.discover_client_host => Off => Off
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.file_link_format => no value => no value
xdebug.filename_format => no value => no value
xdebug.force_display_errors => Off => Off
xdebug.force_error_reporting => 0 => 0
xdebug.gc_stats_enable => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3)
xdebug.gc_stats_output_dir => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3)
xdebug.gc_stats_output_name => gcstats.%p => gcstats.%p
xdebug.halt_level => 0 => 0
xdebug.idekey => no value => no value
xdebug.log => no value => no value
xdebug.log_level => 0 => 0
xdebug.max_nesting_level => 256 => 256
xdebug.max_stack_frames => -1 => -1
xdebug.mode => debug => debug
xdebug.output_dir => /tmp => /tmp
xdebug.overload_var_dump => (setting removed in Xdebug 3) => (setting removed in Xdebug 3)
xdebug.profiler_append => Off => Off
xdebug.profiler_enable => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3)
xdebug.profiler_enable_trigger => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3)
xdebug.profiler_enable_trigger_value => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3)
xdebug.profiler_output_dir => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3)
xdebug.profiler_output_name => cachegrind.out.%p => cachegrind.out.%p
xdebug.remote_autostart => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3)
xdebug.remote_connect_back => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3)
xdebug.remote_enable => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3)
xdebug.remote_host => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3)
xdebug.remote_log => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3)
xdebug.remote_log_level => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3)
xdebug.remote_mode => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3)
xdebug.remote_port => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3)
xdebug.remote_timeout => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3)
xdebug.scream => Off => Off
xdebug.show_error_trace => Off => Off
xdebug.show_exception_trace => Off => Off
xdebug.show_local_vars => Off => Off
xdebug.show_mem_delta => (setting removed in Xdebug 3) => (setting removed in Xdebug 3)
xdebug.start_upon_error => default => default
xdebug.start_with_request => no => no
xdebug.trace_enable_trigger => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3)
xdebug.trace_enable_trigger_value => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3)
xdebug.trace_format => 0 => 0
xdebug.trace_options => 0 => 0
xdebug.trace_output_dir => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3)
xdebug.trace_output_name => trace.%c => trace.%c
xdebug.trigger_value => no value => no value
xdebug.use_compression => 0 => 0
xdebug.var_display_max_children => 128 => 128
xdebug.var_display_max_data => 512 => 512
xdebug.var_display_max_depth => 3 => 3

有趣的是,我甚至试图完全卸载XDEBUG,但仍然存在同样的问题(我不确定我是否做得正确)。

我有什么办法阻止XDEBUG建立连接吗?(只有在我实际需要调试时才启用它)

我使用的是PHP7.4.25,XDEBUG v3.1.1,并在Windows(Ubuntu 20.04)上的WSL下运行它。我还在运行nginx v1.21.4之后的所有内容。

更新1: 正如@LazyOne所问的,下面是我的xdebug_info()输出:

screenshot of xdebug_info output

second part of xdebug_info

更新2

以下是/etc/php/7.4/fpm/conf.d/xdebug.ini的输出:

[xdebug]
xdebug.mode=debug
xdebug.start_with_request=no
xdebug.discover_client_host=no
xdebug.client_host=127.0.0.1
xdebug.log_level=0
xdebug.connect_timeout_ms=0
;xdebug.log=/var/log/xdebug.log
#zend_extension=xdebug.so
#xdebug.mode=debug
#xdebug.start_with_request=yes
#xdebug.start_upon_error=yes
#xdebug.discover_client_host=yes
#xdebug.client_host=10.0.10.1
#xdebug.client_port=9000
#xdebug.log_level=0
#xdebug.log=/var/log/xdebug.log
#xdebug.profiler_enable=1
#xdebug.remote_enable=1
#xdebug.remote_handler=dbgp
#xdebug.remote_mode=req
#xdebug.remote_autostart=1
#xdebug.remote_connect_back=1
#xdebug.idekey=PHPSTORM
#xdebug.show_exception_trace

这也是我的/etc/php/7.4/fpm/conf.d/20-xdebug.ini

[xdebug]
zend_extension=xdebug.so
xdebug.mode=debug
xdebug.start_with_request=no
xdebug.discover_client_host=no
xdebug.client_host=127.0.0.1
xdebug.log_level=10
xdebug.remote_autostart = 0
xdebug.log=/tmp/xdebug/xdebug.log
xdebug.connect_timeout_ms=0

这是grep -Ri xdebug /etc/php/7.4/fpm/conf.d/的输出:

root@DESKTOP-UB3H2M6:/var/www# grep -Ri xdebug /etc/php/7.4/fpm/conf.d/
/etc/php/7.4/fpm/conf.d/20-xdebug.ini:[xdebug]
/etc/php/7.4/fpm/conf.d/20-xdebug.ini:zend_extension=xdebug.so
/etc/php/7.4/fpm/conf.d/20-xdebug.ini:xdebug.mode=debug
/etc/php/7.4/fpm/conf.d/20-xdebug.ini:xdebug.start_with_request=no
/etc/php/7.4/fpm/conf.d/20-xdebug.ini:xdebug.discover_client_host=no
/etc/php/7.4/fpm/conf.d/20-xdebug.ini:xdebug.client_host=127.0.0.1
/etc/php/7.4/fpm/conf.d/20-xdebug.ini:xdebug.log_level=10
/etc/php/7.4/fpm/conf.d/20-xdebug.ini:xdebug.remote_autostart = 0
/etc/php/7.4/fpm/conf.d/20-xdebug.ini:xdebug.log=/tmp/xdebug/xdebug.log
/etc/php/7.4/fpm/conf.d/20-xdebug.ini:xdebug.connect_timeout_ms=0
/etc/php/7.4/fpm/conf.d/xdebug.ini:[xdebug]
/etc/php/7.4/fpm/conf.d/xdebug.ini:xdebug.mode=debug
/etc/php/7.4/fpm/conf.d/xdebug.ini:xdebug.start_with_request=no
/etc/php/7.4/fpm/conf.d/xdebug.ini:xdebug.discover_client_host=no
/etc/php/7.4/fpm/conf.d/xdebug.ini:xdebug.client_host=127.0.0.1
/etc/php/7.4/fpm/conf.d/xdebug.ini:xdebug.log_level=0
/etc/php/7.4/fpm/conf.d/xdebug.ini:xdebug.connect_timeout_ms=0
/etc/php/7.4/fpm/conf.d/xdebug.ini:;xdebug.log=/var/log/xdebug.log
/etc/php/7.4/fpm/conf.d/xdebug.ini:#zend_extension=xdebug.so
/etc/php/7.4/fpm/conf.d/xdebug.ini:#xdebug.mode=debug
/etc/php/7.4/fpm/conf.d/xdebug.ini:#xdebug.start_with_request=yes
/etc/php/7.4/fpm/conf.d/xdebug.ini:#xdebug.start_upon_error=yes
/etc/php/7.4/fpm/conf.d/xdebug.ini:#xdebug.discover_client_host=yes
/etc/php/7.4/fpm/conf.d/xdebug.ini:#xdebug.client_host=10.0.10.1
/etc/php/7.4/fpm/conf.d/xdebug.ini:#xdebug.client_port=9000
/etc/php/7.4/fpm/conf.d/xdebug.ini:#xdebug.log_level=0
/etc/php/7.4/fpm/conf.d/xdebug.ini:#xdebug.log=/var/log/xdebug.log
/etc/php/7.4/fpm/conf.d/xdebug.ini:#xdebug.profiler_enable=1
/etc/php/7.4/fpm/conf.d/xdebug.ini:#xdebug.remote_enable=1
/etc/php/7.4/fpm/conf.d/xdebug.ini:#xdebug.remote_handler=dbgp
/etc/php/7.4/fpm/conf.d/xdebug.ini:#xdebug.remote_mode=req
/etc/php/7.4/fpm/conf.d/xdebug.ini:#xdebug.remote_autostart=1
/etc/php/7.4/fpm/conf.d/xdebug.ini:#xdebug.remote_connect_back=1
/etc/php/7.4/fpm/conf.d/xdebug.ini:#xdebug.idekey=PHPSTORM
/etc/php/7.4/fpm/conf.d/xdebug.ini:#xdebug.show_exception_trace

推荐答案

我是否可以阻止XDEBUG侦听?

不会,因为监听的不是XDEBUG。XDEBUG与PhpStorm建立连接,PhpStorm可以侦听传入的调试连接。

可能由于某些原因,XDEBUG仍然尝试建立到IDE的连接,即使它没有侦听。连接时,XDEBUG端通常有200毫秒的超时,但我看到一些网络设置阻止了这一点。

为了查明XDEBUG是否仍在执行某些操作,请创建一个日志文件,方法是将xdebug.ini更改为包括以下内容,然后重新启动Apache:

xdebug.log_level=10 
xdebug.log=/var/log/xdebug.log

日志文件将详细显示Xdebug是否仍在尝试连接(因为您将xdebug.log_level设置为10)。

792