首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Xdebug在php7.3的nginx上不工作

Xdebug在php7.3的nginx上不工作
EN

Stack Overflow用户
提问于 2019-12-12 20:05:20
回答 1查看 2K关注 0票数 0

我已经使用phpdockerio/php73-fpm:latest的php7.3设置了一个docker容器。xdebug安装正确,但它不调试任何东西。我不能做到这一点,所以我需要一些指导。

这是我的码头配置:

nginx配置

代码语言:javascript
运行
复制
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输出

代码语言:javascript
运行
复制
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

文档

代码语言:javascript
运行
复制
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

代码语言:javascript
运行
复制
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的输出

代码语言:javascript
运行
复制
 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"
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-12-16 06:44:46

好的,我终于让它在评论的帮助下起作用了。我唯一需要改变的是下面这一行:

先于

代码语言:javascript
运行
复制
XDEBUG_CONFIG: "remote_host=172.29.0.4 remote_port=9001 idekey=\"PHPSTORM\" remote_log=\"/var/log/xdebug.log\""

代码语言:javascript
运行
复制
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

  • remote_port

  • remote_host ->从172.23.0.3到172.29.0.1,根据注释检查删除了-> ->。默认端口是9000,这是免费的,基于

  • remote_enable =1- netstat -anp | grep CLOSE_WAIT。基于其他堆栈溢出findings

  • remote_autostart =1-添加。基于其他堆栈溢出发现
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59311969

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档