LoginSignup
27
21

More than 3 years have passed since last update.

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

Posted at

経緯

既存の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"]

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

27
21
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
27
21