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

17k Views Asked by At

I want to install php-zip on my docker image (the end goal is to use the PhpWord Library). I use the php:7.4-fpm, which runs on Debian.

In my dockerfile, i use the command :

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

When executed, the script crashes because it can't find /usr/src/php/ext/libzip.

So i add a good old "apt-get install libzip", but it can't locate the package. Same thing if it try to install "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

I assume either libzip4 isn't a valid version or it can't make the link between libzip and libzip4.

The main issue is that, without that library, i'm stuck and can't install the extension at all. Also i'm quiet a rookie when it comes to docker so i call out your help !

Thanks for your time !

1

There are 1 best solutions below

2
On BEST ANSWER

Ok, so the issue is that you have to guess that the package you need to install is called "libzip-dev", not just "libzip".

So the solution was :

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