我已经使用phpdockerio/php73-fpm:latest
的php7.3设置了一个docker容器。xdebug安装正确,但它不调试任何东西。我不能做到这一点,所以我需要一些指导。
这是我的码头配置:
nginx配置
server {
server_name lxxxxxv2.local;
listen 443 default_server ssl;
root /app/public;
ssl on;
ssl_certificate /etc/nginx/ssl/lxxxxxxv2.local.crt;
ssl_certificate_key /etc/nginx/ssl/lxxxxxv2.local.key;
location / {
# try to serve file directly, fallback to app.php
try_files $uri /index.php$is_args$args;
}
# DEV
# This rule should only be placed on your development environment
# In production, don't include this and don't deploy app_dev.php or config.php
location ~ ^/(index_dev|config)\.php(/|$) {
fastcgi_pass lxxxxv2-php-fpm:9000;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
# When you are using symlinks to link the document root to the
# current version of your application, you should pass the real
# application path instead of the path to the symlink to PHP
# FPM.
# Otherwise, PHP's OPcache may not properly detect changes to
# your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
# for more information).
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
}
# PROD
location ~ ^/index\.php(/|$) {
fastcgi_pass lxxxxv2-php-fpm:9000;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
# When you are using symlinks to link the document root to the
# current version of your application, you should pass the real
# application path instead of the path to the symlink to PHP
# FPM.
# Otherwise, PHP's OPcache may not properly detect changes to
# your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
# for more information).
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
# Prevents URIs that include the front controller. This will 404:
# http://symfony3.dev/app.php/some-path
# Remove the internal directive to allow URIs like this
internal;
}
# return 404 for all other php files not matching the front controller
# this prevents access to other php files you don't want to be accessible.
location ~ \.php$ {
return 404;
}
error_log /var/log/nginx/lxxxxv2_error.log;
access_log /var/log/nginx/lxxxxv2_access.log;
}
php输出
root@9736f96a32ef:/app# php -v
PHP 7.3.12-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Nov 28 2019 07:37:16) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.12, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.12-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
with Xdebug v2.8.1, Copyright (c) 2002-2019, by Derick Rethans
文档
FROM phpdockerio/php73-fpm:latest
WORKDIR "/app"
# Fix debconf warnings upon build
ARG DEBIAN_FRONTEND=noninteractive
#add yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
# Install selected extensions and other stuff
RUN apt-get update \
&& apt-get -y --no-install-recommends install \
vim \
nodejs \
npm \
yarn \
php7.3-mysql \
php-redis \
php7.3-xdebug \
php7.3-gd \
php7.3-intl \
php7.3-fpm \
php7.3-mongodb \
iputils-ping
RUN apt-get update \
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
码头-Compose.yml
lxxxxv2-webserver:
image: nginx:alpine
container_name: lxxxxxv2-webserver
working_dir: /app
volumes:
- .:/app
- ./log:/log
- ./Dockerconfig/nginx/nginx.conf:/etc/nginx/conf.d/default.conf
- ./Dockerconfig/sslcerts/lxxxxxv2.local.crt:/etc/nginx/ssl/lxxxxxv2.local.crt
- ./Dockerconfig/sslcerts/lxxxxxv2.local.key:/etc/nginx/ssl/lxxxxxxv2.local.key
depends_on:
- lxxxxv2-php-fpm
- lxxxxv2-mysql
links:
- lxxxxv2-php-fpm
- lxxxxv2-mysql
ports:
- "30080:80"
- "30443:443"
expose:
- "80"
- "443"
mem_limit: 300m
memswap_limit: 300m
environment:
- VIRUAL_HOST=lxxxxxv2.local
- APP_FRONT_CONTROLLER=public/index.php
networks:
default:
aliases:
- lxxxxxxv2.local
lxxxxv2-php-fpm:
build: Dockerconfig/php-fpm
container_name: lxxxxv2-php-fpm
working_dir: /app
volumes:
- .:/app
- ./log:/log
- ./Dockerconfig/php-fpm/php-ini-overrides.ini:/etc/php/7.3/fpm/conf.d/99-overrides.ini
ports:
- "30901:9000"
expose:
- "30901"
extra_hosts:
- "lxxxxv2.local:0.0.0.0"
networks:
- default
environment:
XDEBUG_CONFIG: "remote_host=172.29.0.3 idekey=\"PHPSTORM\" remote_port=9001 remote_connect_back=1 remote_log=\"/var/log/xdebug.log\""
PHP_IDE_CONFIG: "serverName=lxxxxv2.local"
phpstorm服务器设置:
phpstorm调试设置:
php风暴DBGp设置:
与
相关的php -i的输出
php -i | grep -i xdebug
/etc/php/7.3/cli/conf.d/20-xdebug.ini,
with Xdebug v2.8.1, Copyright (c) 2002-2019, by Derick Rethans
xdebug
xdebug support => enabled
Support Xdebug on Patreon, GitHub, or as a business: https://xdebug.org/support
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.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 => Off => Off
xdebug.gc_stats_output_dir => /tmp => /tmp
xdebug.gc_stats_output_name => gcstats.%p => gcstats.%p
xdebug.halt_level => 0 => 0
xdebug.idekey => no value => no value
xdebug.max_nesting_level => 256 => 256
xdebug.max_stack_frames => -1 => -1
xdebug.overload_var_dump => 2 => 2
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_addr_header => no value => no value
xdebug.remote_autostart => Off => Off
xdebug.remote_connect_back => Off => Off
xdebug.remote_cookie_expire_time => 3600 => 3600
xdebug.remote_enable => Off => Off
xdebug.remote_handler => dbgp => dbgp
xdebug.remote_host => 172.29.0.1 => localhost
xdebug.remote_log => "/var/log/xdebug.log" => no value
xdebug.remote_log_level => 7 => 7
xdebug.remote_mode => req => req
xdebug.remote_port => 9000 => 9000
xdebug.remote_timeout => 200 => 200
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 => 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_CONFIG => remote_host=172.29.0.1 idekey="PHPSTORM" remote_log="/var/log/xdebug.log"
$_SERVER['XDEBUG_CONFIG'] => remote_host=172.29.0.1 idekey="PHPSTORM" remote_log="/var/log/xdebug.log"
发布于 2019-12-16 06:44:46
好的,我终于让它在评论的帮助下起作用了。我唯一需要改变的是下面这一行:
先于
XDEBUG_CONFIG: "remote_host=172.29.0.4 remote_port=9001 idekey=\"PHPSTORM\" remote_log=\"/var/log/xdebug.log\""
后
XDEBUG_CONFIG: "remote_host=172.29.0.1 idekey=\"PHPSTORM\" remote_connect_back=1 remote_log=\"/var/log/xdebug.log\""
netstat -rn | grep "^0.0.0.0 " | cut -d " " -f10
netstat -anp | grep CLOSE_WAIT
。基于其他堆栈溢出findings
https://stackoverflow.com/questions/59311969
复制相似问题