我使用安装了apache2,php7和xdebug的docker容器进行了设置。主机系统运行ubuntu 16.04。我已经在主机上安装了eclipse neon最新下载,并尝试了许多不同的配置来让xdebug工作。我已将容器配置为公开端口80和9000,并已配置xdebug以进行远程启动和端口9000使用。当我尝试配置eclipse调试时,它告诉我端口9000正在使用中并且不会连接。我在网上搜索了任何有用的信息,但没有提供任何信息。
以下是docker容器的Web服务器配置代码:
FROM php:7.0.19-apache
COPY config/php.ini /usr/local/etc/php/
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng12-dev \
git \
&& docker-php-ext-install -j$(nproc) iconv mcrypt \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd\
&& docker-php-ext-install -j$(nproc) mysqli\
&& pecl install xdebug-2.5.0 \
&& docker-php-ext-enable xdebug
# Installation of Composer
RUN cd /usr/src && curl -sS http://getcomposer.org/installer | php
RUN cd /usr/src && mv composer.phar /usr/bin/composer
# Installation of tools with composer
RUN composer global require --no-plugins --no-scripts phpdocumentor/phpdocumentor
RUN composer global require --no-plugins --no-scripts squizlabs/php_codesniffer
RUN composer global require --no-plugins --no-scripts phpunit/phpunit
RUN composer global require --no-plugins --no-scripts phpunit/dbunit
RUN composer global require --no-plugins --no-scripts phploc/phploc
RUN composer global require --no-plugins --no-scripts phpmd/phpmd
RUN composer global require --no-plugins --no-scripts simpletest/simpletest
ENV PATH /root/.composer/vendor/bin:$PATH
以下是xdebug的php.ini设置:
zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20151012/xdebug.so
xdebug.profiler_enable_trigger = 1
xdebug.trace_enable_trigger = 1
xdebug.remote_enable=1
xdebug.remote_host=172.18.0.1
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
这是docker-compose代码,用于公开数据库容器中的端口和链接:
version: '2'
services:
webserver:
build: ./docker/webserver
ports:
- "80:80"
- "443:443"
- "9000:9000"
volumes:
- /home/www:/var/www
links:
- db
db:
image: mysql:5.5
ports:
- "3306:3306"
volumes:
- ./db:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=mypassword
myadmin:
image: phpmyadmin/phpmyadmin:4.6
ports:
- "8080:80"
links:
- db
environment:
MYSQL_ROOT_PASSWORD: mypassword
我很感激帮助调试器工作,以便我可以使用它来设置断点。我为firefox安装了最新的xdebug扩展,并打算在我将所有内容都工作时将其用作调试控件。
提前致谢。