docker php7.4修复pecl/xdebug requires PHP (version >= 8.0.0, version <= 8.2.99), installed version is 7.4.33

post by rocdk890 / 2023-2-24 11:21 Friday linux技术
系统:centos 7.x(64位)
最近看到php官网把php7.4的dockerfile全都给删了,最后的版本是在7.4.33,而我的php镜像是7.4.26,所以打算把我自己的php镜像给升级下,但在build的时候居然出现error: 'xdebug' does not exist.
下面是解决办法:
这里的解决办法是你不想升级到 php8 的方法,安装旧版本的 xdebug 3.1.5.
pecl install xdebug-3.1.5

所以在dockerfile里,可以直接写xdebug-3.1.5 

下面是我php-fpm 7.4.33的dockerfile:
FROM rocdk890/php-fpm:7.4.33-alpine3.16 

MAINTAINER rocdk890 <rocdk890@gmail.com>

ENV \
  XHPROF_VERSION=5.0.1\
  ZEPHIR_VERSION=1.3.3 \
  PHALCON_VERSION=4.0.0 \
  SWOOLE_VERSION=4.6.7 \
  SWOOLE_ASYNC_VERSION=4.5.5 \
  LD_PRELOAD=/usr/lib/preloadable_libiconv.so \
  PECL_EXTENSIONS="apcu ast ds ev grpc hrtime igbinary imagick lzf lua mongodb msgpack oauth pcov psr rdkafka redis \
    ssh2-1.2 uuid xdebug-3.1.5 xlswriter yaf yaml" \
  PECL_BUNDLE="memcached event" \
  PHP_EXTENSIONS="bcmath bz2 calendar exif gd gettext gmp imap intl ldap mysqli pcntl pdo_mysql pgsql pdo_pgsql \
    soap sockets swoole sysvshm sysvmsg sysvsem tidy zip zephir_parser"

RUN \
# deps
  apk add -U --no-cache --virtual temp \
    # dev deps
    autoconf g++ file re2c make zlib-dev libtool pcre-dev libxml2-dev bzip2-dev libzip-dev \
      icu-dev gettext-dev imagemagick-dev openldap-dev libpng-dev gmp-dev yaml-dev postgresql-dev \
      libxml2-dev tidyhtml-dev libmemcached-dev libssh2-dev libevent-dev libev-dev librdkafka-dev lua-dev \
      freetype-dev jpeg-dev libjpeg-turbo-dev oniguruma-dev \
    # prod deps
    && apk add --no-cache icu gettext gnu-libiconv grpc imagemagick libzip libbz2 libxml2-utils openldap-back-mdb openldap yaml \
      libpq tidyhtml imap-dev libmemcached libssh2 libevent libev librdkafka linux-headers lua zlib \
#
# php extensions
  && docker-php-source extract \
    && pecl channel-update pecl.php.net \
    && pecl install $PECL_EXTENSIONS > /dev/null \
    && cd /usr/src/php/ext/ \
    && for BUNDLE_EXT in $PECL_BUNDLE; do pecl bundle $BUNDLE_EXT; done \
    && docker-php-ext-enable $(echo $PECL_EXTENSIONS | sed -E 's/\-[^ ]+//g') opcache \
    # swoole
    && curl -sSLo swoole.tar.gz https://github.com/swoole/swoole-src/archive/v$SWOOLE_VERSION.tar.gz \
      && curl -sSLo swoole_async.tar.gz https://github.com/swoole/ext-async/archive/v$SWOOLE_ASYNC_VERSION.tar.gz \
      && tar xzf swoole.tar.gz && tar xzf swoole_async.tar.gz \
      && mv swoole-src-$SWOOLE_VERSION swoole && mv ext-async-$SWOOLE_ASYNC_VERSION swoole_async \
      && rm -f swoole.tar.gz swoole_async.tar.gz \
    # zephir_parser
    && curl -sSLo zephir_parser.tar.gz https://github.com/phalcon/php-zephir-parser/archive/v$ZEPHIR_VERSION.tar.gz \
      && tar xzf zephir_parser.tar.gz \
      && rm -f zephir_parser.tar.gz \
      && mv php-zephir-parser-$ZEPHIR_VERSION zephir_parser \
    && docker-php-ext-configure gd --with-freetype --with-jpeg --enable-gd \
    && docker-php-ext-install -j "$(nproc)" $PHP_EXTENSIONS $PECL_BUNDLE > /dev/null \
    && cd /usr/local/etc/php/conf.d/ \
      && mv docker-php-ext-event.ini docker-php-ext-zevent.ini \
    && pecl clear-cache \
  && docker-php-source delete \
#
# tideways_xhprof
  && curl -sSLo /tmp/xhprof.tar.gz https://github.com/tideways/php-xhprof-extension/archive/v$XHPROF_VERSION.tar.gz \
    && cd /tmp/ && tar xzf xhprof.tar.gz && cd php-xhprof-extension-$XHPROF_VERSION \
    && phpize && ./configure \
    && make -j "$(nproc)" && make install \
    && docker-php-ext-enable tideways_xhprof \
#
# phalcon
  && curl -sSLo /tmp/phalcon.tar.gz https://codeload.github.com/phalcon/cphalcon/tar.gz/v$PHALCON_VERSION \
    && cd /tmp/ && tar xzf phalcon.tar.gz \
    && cd cphalcon-$PHALCON_VERSION/build && sh install \
    && docker-php-ext-enable phalcon --ini-name docker-php-ext-phalcon.ini \
#
# composer
  && curl -sSL https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer2 \
  && curl -sSL https://getcomposer.org/installer | php -- --1 --install-dir=/usr/local/bin --filename=composer \
#  && composer global require hirak/prestissimo \
#
# cleanup
  && apk del temp \
    && rm -rf /var/cache/apk/* /tmp/* /var/tmp/* /usr/share/doc/* /usr/share/man/*

# docker-php-ext-disable
COPY docker-php-ext-disable.sh /usr/local/bin/docker-php-ext-disable

WORKDIR /webroot


当然你们也可以直接docker pull rocdk890/php-fpm:7.4.33-alp3.16
夜空- 本站版权
1、本站所有主题由该文章作者发表,该文章作者与夜空享有文章相关版权
2、其他单位或个人使用、转载或引用本文时必须同时征得该文章作者和夜空的同意
3、本帖部分内容转载自其它媒体,但并不代表本站赞同其观点和对其真实性负责
4、如本帖侵犯到任何版权问题,请立即告知本站,本站将及时予与删除并致以最深的歉意
5、原文链接:blog.slogra.com/post-800.html

标签: centos php-fpm php docker php7.4.33 xdebug pecl

评论: