6

我想在我的 docker 镜像上安装 php-zip(最终目标是使用 PhpWord 库)。我使用在 Debian 上运行的 php:7.4-fpm。

在我的 dockerfile 中,我使用命令:

RUN apt-get update docker-php-ext-install zip

执行时,脚本会因为找不到 /usr/src/php/ext/libzip 而崩溃。

所以我添加了一个很好的旧“apt-get install libzip”,但它找不到包。如果它尝试安装 "libzip4" 也是一样的:

checking for libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0... no
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 'webapi' failed to build : The command '/bin/sh -c apt-get update          &&       apt-get install libzip4          && docker-php-ext-install zip' returned a non-zero code: 1

我假设 libzip4 不是有效版本,或者它无法在 libzip 和 libzip4 之间建立链接。

主要问题是,没有那个库,我被卡住了,根本无法安装扩展。在 docker 方面,我也是一个安静的菜鸟,所以我呼吁你的帮助!

谢谢你的时间 !

4

1 回答 1

23

好的,所以问题是您必须猜测您需要安装的软件包称为“libzip-dev”,而不仅仅是“libzip”。

所以解决方案是:

RUN apt-get update \
     && apt-get install -y libzip-dev \
     && docker-php-ext-install zip
于 2020-10-23T13:19:47.187 回答