3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

開発環境(Docker)のPHPのバージョンを7.2.11から7.4.xにアップデートした時にハマったこと

Last updated at Posted at 2021-01-04

開発環境のPHPのバージョンを7.2.11から7.4.xにアップデートするために、既存のDockerfileを編集することになった。

実現したかったこと

開発環境(Docker)のPHPのバージョンを7.2.11から7.4.xにアップデートする。


# Dockerfile

# ↓これを7.4.xにしたい
FROM php:7.2.11-apache 

RUN apt-get update \
&& apt-get install -y zlib1g-dev \
&& docker-php-ext-install zip \
&& apt-get install -y unzip

結論

最終的にはこの形になった。

# Dockerfile

FROM php:7.4.13-apache

RUN apt-get update \
&& apt-get install -y zlib1g-dev \
&& apt-get install -y libzip-dev \
&& docker-php-ext-install zip \
&& apt-get install -y unzip

やったこと

DockerHubを見ると、7.4.13-apacheというイメージがあったので、とりあえず変えてみた。


# Dockerfile

# ↓7.4.13に変えた
FROM php:7.4.13-apache

RUN apt-get update \
&& apt-get install -y zlib1g-dev \
&& docker-php-ext-install zip \
&& apt-get install -y unzip

しかし。。。

$ docker-compose build
...
...
configure: error: Package requirements (libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0) were not met:

No package 'libzip' found
No package 'libzip' found
No package 'libzip' 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 LIBZIP_CFLAGS
and LIBZIP_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
ERROR: Service 'service_name' failed to build : The command '/bin/sh -c apt-get update && apt-get install -y zlib1g-dev && docker-php-ext-install zip && apt-get install -y unzip' returned a non-zero code: 1

libzipとかいうやつが無いらしい…
なので、apt-get install libzip-devを追加した。

FROM php:7.4.13-apache

# zlib zip unzip
RUN apt-get update \
&& apt-get install -y zlib1g-dev \
&& apt-get install libzip-dev \
&& docker-php-ext-install zip \
&& apt-get install -y unzip

すると…

$ docker-compose build
...
略
...
The following package was automatically installed and is no longer required:
  sensible-utils
Use 'apt autoremove' to remove it.
The following additional packages will be installed:
  libzip4
The following NEW packages will be installed:
  libzip-dev libzip4
0 upgraded, 2 newly installed, 0 to remove and 2 not upgraded.
Need to get 209 kB of archives.
After this operation, 436 kB of additional disk space will be used.
Do you want to continue? [Y/n] Abort.

-yオプションがないということかな?
というわけで、

# Dockerfile

FROM php:7.4.13-apache

RUN apt-get update \
&& apt-get install -y zlib1g-dev \
&& apt-get install -y libzip-dev \
&& docker-php-ext-install zip \
&& apt-get install -y unzip

-yオプションを追加して再度$ docker-compose buildを実行。

$ docker-compose build
...
...
Successfully built ******
Successfully tagged app_name:latest

うまくいった!!

参考記事

stack oveflow
Installing PHP-zip on a php:7.4-fpm image

3
2
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
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?