以前我已经用Docker容器和Windows主机设置了Xdebug,并想对我的Ubuntu分区做类似的事情,但是我似乎永远无法连接。
我已经检查了活动端口,并且我的IDE(VS代码)正在9000上侦听。运行代码时,我的XDebug日志中出现以下错误:
[16] W: Creating socket for '172.2.0.3:9000', poll success, but error: Operation now in progress (29).
[16] E: Could not connect to client. :-(
我的Dockerfile:
FROM php:7.3-apache-stretch
RUN apt-get update
RUN apt-get install zip -y
RUN pecl install xdebug-2.7.0 \
&& docker-php-ext-enable xdebug
RUN touch /var/log/xdebug.log
RUN chmod 777 /var/log/xdebug.log
RUN docker-php-ext-install pdo_mysql
RUN apt-get install git -y
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
php -r "if (hash_file('sha384', 'composer-setup.php') === '48e3236262b34d30969dca3c37281b3b4bbe3221bda826ac6a9a62d6444cdb0dcd0615698a5cbe587c3f0fe57a54d8f5') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && \
php composer-setup.php && \
php -r "unlink('composer-setup.php');" && \
mv composer.phar /usr/local/bin/composer
COPY php.ini $PHP_INI_DIR/
COPY docker-php-ext-xdebug.ini $PHP_INI_DIR/conf.d/
WORKDIR /var/www/html
还有我的xdebug.ini:
zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so
xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.remote_port=9000
; xdebug.remote_connect_back=1
; xdebug.max_nesting_level=1000
xdebug.idekey=VSCODE
xdebug.remote_host=172.2.0.3
xdebug.remote_log=/var/log/xdebug.log
我不知道我还可以测试或设置什么以使Xdebug正常工作。