Alpine 3.17 Docker环境安装Xdebug失败,求解决方法
在Alpine 3.17环境中安装Xdebug遇到困境
我在Alpine 3.17环境下尝试安装Xdebug,试过多种谷歌找到的方案都无效,目前卡住了。
我尝试用PECL安装Xdebug,执行pecl install xdebug时收到如下错误:
#7 ERROR: process "/bin/sh -c pecl install xdebug" did not complete successfully: exit code: 127 ------ > [ 3/34] RUN pecl install xdebug: #7 0.416 /bin/sh: pecl: not found ------ Dockerfile:30 -------------------- 28 | composer 29 | 30 | >>> RUN pecl install xdebug 31 | RUN docker-php-ext-enable xdebug 32 | -------------------- ERROR: failed to solve: process "/bin/sh -c pecl install xdebug" did not complete successfully: exit code: 127
我的Dockerfile内容如下:
FROM alpine:3.17 RUN set -x \ && apk add --no-cache \ tzdata \ bash \ vim \ supervisor \ nginx \ nginx-mod-http-headers-more \ gcc \ musl-dev \ php81 \ php81-phar \ php81-fpm \ php81-curl \ php81-redis \ php81-opcache \ php81-mysqlnd \ php81-pdo_mysql \ php81-tokenizer \ php81-dom \ php81-fileinfo \ php81-xml \ php81-xmlwriter \ php81-xmlreader \ composer RUN pecl install xdebug RUN docker-php-ext-enable xdebug RUN ln -s /usr/share/zoneinfo/Europe/Berlin /etc/localtime RUN mkdir /etc/supervisor.d RUN mkdir /etc/nginx/snippets RUN mkdir /etc/nginx/conf.d RUN mkdir /run/php RUN mkdir /srv/ylvi COPY docker/supervisord.conf /etc/supervisord.conf COPY docker/supervisor-php-fpm81.ini /etc/supervisor.d/php-fpm81.ini COPY docker/supervisor-nginx.ini /etc/supervisor.d/nginx.ini COPY docker/supervisor-cron.ini /etc/supervisor.d/cron.ini COPY docker/nginx.conf /etc/nginx/nginx.conf COPY docker/nginx-mo.conf /etc/nginx/snippets/mo.conf COPY docker/nginx-fastcgi-php.conf /etc/nginx/snippets/fastcgi-php.conf COPY docker/nginx-php8.1-fpm.conf /etc/nginx/snippets/php8.1-fpm.conf COPY docker/nginx-chk.conf /etc/nginx/http.d/nginx-chk.conf COPY docker/nginx-ylvi.conf /etc/nginx/http.d/ylvi.conf RUN rm -f /etc/nginx/http.d/default.conf COPY docker/health_check.php /var/www/localhost/htdocs/health_check.php COPY docker/php-mo.ini /etc/php81/conf.d/99_mo.ini COPY docker/php-fpm.conf /etc/php81/php-fpm.conf COPY docker/php-www.conf /etc/php81/php-fpm.d/www.conf WORKDIR /srv/www RUN /bin/touch storage/logs/laravel.log RUN /bin/chown nginx:nginx -R /srv/ylvi # Add the cron job RUN crontab -l | { cat; cat docker/crontab.conf; } | crontab - EXPOSE 10080 CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]
我已经尝试过以下方法,但都没解决问题:
- 添加
$PHPIZE_DEPS依赖 - 尝试用
php8.1-pecl-xdebug直接替代PECL安装方式 - 添加
musl-dev和gcc编译依赖
我看到不少人在Alpine环境用PECL遇到问题,但情况和我不太一样。请问有没有解决这个问题的建议?
内容的提问来源于stack exchange,提问作者MIB
相关产品推荐
相关产品推荐

