我试图在Alpine 3.17上安装Xdebug,但我在Google上找到的不同解决方案没有成功。这事我有点糊涂了。
我尝试使用PECL安装这里提到的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 install
。此外,正如您所看到的,我添加了musl-dev
和gcc
到apk添加,但无济于事。我还发现,有更多的人在Alpine (https://github.com/docker-library/php/issues/1134)下有PECL问题,但这似乎不是我的问题。
线索在:#7 0.416/bin/sh: pecl: not found.
如果你想使用pecl
,你需要在安装apk
的同时安装php81-pear
,但是一般来说,当php81-pecl-xdebug
这样的包已经可用时,你不应该编译你自己的扩展。
你没有说为什么安装那个不工作。