Quantcast
Channel: PHP7.4タグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 113

php7.4-apacheイメージのビルド時に "No package 'oniguruma' found" エラーが発生する際の対処

$
0
0

経緯

既存のDocker+php環境を、php7.4にアップグレードすることになりました。

↓元のDockerfile

FROM php:7.3-apache
COPY ./etc/docker/app/conf/*.conf /etc/apache2/sites-available/

RUN apt-get update && apt-get install -y vim zip unzip

RUN set -ex apk --no-cache add postgresql-dev libpq-dev
RUN apt-get install -y libpq-dev \
    && docker-php-ext-install pdo pdo_pgsql pgsql mbstring

RUN pecl install xdebug && \
    docker-php-ext-enable xdebug
COPY ./etc/docker/app/php_conf/xdebug.ini /usr/local/etc/php/conf.d/

RUN a2enmod rewrite

EXPOSE 80

CMD ["apache2-foreground"]

ここからimageの部分を php:7.4-apacheに書き換えてビルドしたところ、以下のエラーが出ました。

configure: error: Package requirements (oniguruma) were not met:

No package 'oniguruma' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables ONIG_CFLAGS
and ONIG_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

解決方法

https://github.com/docker-library/php/issues/880
こちらによると、 mbstringに替わり libonig-devというパッケージを追加する必要があるそう。
以下のように書き換えます。

FROM php:7.4-apache
COPY ./etc/docker/app/conf/*.conf /etc/apache2/sites-available/

RUN apt-get update && apt-get install -y vim zip unzip

RUN set -ex apk --no-cache add postgresql-dev libpq-dev
RUN apt-get install -y libpq-dev \
    libonig-dev \ # 追加
    && docker-php-ext-install pdo pdo_pgsql pgsql # mbstringは削除

RUN pecl install xdebug && \
    docker-php-ext-enable xdebug
COPY ./etc/docker/app/php_conf/xdebug.ini /usr/local/etc/php/conf.d/

RUN a2enmod rewrite

EXPOSE 80

CMD ["apache2-foreground"]

これで正常にビルドが完了しました。


Viewing all articles
Browse latest Browse all 113

Trending Articles