在php:7.4-fpm映像上安装PHP-zip

问题描述

我想在我的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来说,我还是个菜鸟,所以我请您帮忙!

感谢您的时间!

解决方法

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

所以解决方案是:

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

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...