Problem
I want to setup a docker based development environment for a PHP application. This environment shall mimic the production server.
This application wants to export an xlsx file and throws Fatal error: Class 'ZipArchive' not found in /var/www/html/lib/xlsxwriter.class.php on line 95
Any attempt to install zip extension for PHP in my docker container fails
fist attempt
#chose the php version here
FROM php:5.4-apache
RUN docker-php-ext-install pdo pdo_mysql mysqli mysql zip
# https://stackoverflow.com/questions/49907308/installing-xdebug-in-docker
# this is for php 7
#RUN yes | pecl install xdebug \
# && echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
# && echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \
# && echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/xdebug.ini
RUN yes | pecl install xdebug-2.4.1 \
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/xdebug.ini
RUN usermod -u 431 www-data
I get configure: error: zip support requires ZLIB. Use --with-zlib-dir=<DIR> to specify prefix where ZLIB include and library are located
second attempt
I have added
RUN docker-php-ext-configure zip --with-zlib-dir=/usr/src/php/ext/zip/ \
&& docker-php-ext-install pdo pdo_mysql mysqli mysql zip
but got configure: error: Can not find zlib headers under "/usr/src/php/ext/zip/"
third attempt
RUN apt-get install libzip /
&& pecl channel-update pecl.php.net && pecl install zip
ends in
configure: error: Please reinstall the libzip distribution
ERROR: `/tmp/pear/temp/zip/configure' failed
other attempts
RUN apt-get update && apt-get install -y zip libzip2 \
&& docker-php-ext-configure zip --with-libzip \
&& docker-php-ext-install zip
W: Failed to fetch http://httpredir.debian.org/debian/dists/jessie-updates/main/binary-amd64/Packages 404 Not Found [IP: 151.101.12.204 80]