Chr*_*ski 19 php docker alpine-linux
我使用的wordpress:php7.1-fpm-alpine是基于php:7.1-fpm-alpine(https://github.com/docker-library/wordpress/blob/master/php7.1/fpm-alpine/Dockerfile).
我试过了 RUN pecl install xdebug-2.5.0 && docker-php-ext-enable xdebug
这会导致构建时出错:
Step 19/19 : RUN pecl install xdebug-2.5.0 && docker-php-ext-enable xdebug
---> Running in 52c988e12cb2
downloading xdebug-2.5.0.tgz ...
Starting to download xdebug-2.5.0.tgz (267,640 bytes)
........................................................done: 267,640 bytes
76 source files, building
running: phpize
Configuring for:
PHP Api Version: 20160303
Zend Module Api No: 20160303
Zend Extension Api No: 320160303
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
Run Code Online (Sandbox Code Playgroud)
tia*_*non 37
以下内容足以简单地在该图像上安装xdebug:
FROM wordpress:php7.1-fpm-alpine
RUN apk add --no-cache $PHPIZE_DEPS \
&& pecl install xdebug-2.5.0 \
&& docker-php-ext-enable xdebug
Run Code Online (Sandbox Code Playgroud)
构建该结构然后从结果图像中的shell运行会产生以下结果:
$ php -i | grep Xdebug
with Xdebug v2.5.0, Copyright (c) 2002-2016, by Derick Rethans
Run Code Online (Sandbox Code Playgroud)
And*_*gan 14
很好的答案@msanchez_aplyca。尽管通过以下方式更正确地删除构建依赖项apk是:
RUN apk add --no-cache --virtual .build-deps $PHPIZE_DEPS \
&& pecl install xdebug-2.5.0 \
&& docker-php-ext-enable xdebug \
&& apk del -f .build-deps
Run Code Online (Sandbox Code Playgroud)
Mau*_*hez 10
如果您担心图像大小,可以删除依赖项:
FROM wordpress:php7.1-fpm-alpine
RUN apk --update --no-cache add autoconf g++ make && \
pecl install -f xdebug && \
docker-php-ext-enable xdebug && \
apk del --purge autoconf g++ make
Run Code Online (Sandbox Code Playgroud)
例如,安装 Xdebug 3.0.0(2020 年 11 月 25 日发布)
兼容 PHP 8.0
RUN apk add --no-cache --virtual .build-deps $PHPIZE_DEPS \
&& pecl install xdebug-3.0.0 \
&& docker-php-ext-enable xdebug \
&& apk del -f .build-deps
Run Code Online (Sandbox Code Playgroud)
现在你通过添加类似的东西来设置它(使用 Xdebug 3.0.0 语法,更多信息在这里):
# Configure Xdebug
RUN echo "xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.log=/var/www/html/xdebug/xdebug.log" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.discover_client_host=1" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.client_port=9000" >> /usr/local/etc/php/conf.d/xdebug.ini
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13536 次 |
| 最近记录: |