问题
我想为 PHP 应用程序设置一个基于 docker 的开发环境。该环境应模拟生产服务器。
此应用程序想要导出一个 xlsx 文件并抛出Fatal error: Class 'ZipArchive' not found in /var/www/html/lib/xlsxwriter.class.php on line 95
任何在我的 docker 容器中安装 PHP zip 扩展的尝试都失败了
拳头尝试
#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
我明白了configure: error: zip support requires ZLIB. Use --with-zlib-dir=<DIR> to specify prefix where ZLIB include and library are located
第二次尝试
我已经添加了
RUN docker-php-ext-configure zip --with-zlib-dir=/usr/src/php/ext/zip/ \
&& docker-php-ext-install pdo pdo_mysql mysqli mysql zip
但得到了configure: error: Can not find zlib headers under "/usr/src/php/ext/zip/"
第三次尝试
RUN apt-get install libzip /
&& pecl channel-update pecl.php.net && pecl install zip
结束于
configure: error: Please reinstall the libzip distribution
ERROR: `/tmp/pear/temp/zip/configure' failed
其他尝试
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]