当前位置: 首页 > 工具软件 > PHP-Ext > 使用案例 >

docker下的php:7.3-apache容器中安装zip拓展报错

戈宏义
2023-12-01

docker下的php:7.3-apache容器中安装zip、redis

以下内容都是在php容器内容进行

安装zip拓展模块

docker-php-ext-install zip

...
checking for the location of zlib... configure: error: zip support requires ZLIB. Use --with-zlib-dir=<DIR> to specify prefix where ZLIB include and library are located

需要指定zlib库路径,因为zip库是依赖zlib库的,使用php -m发现,有zlib模块啊
于是结合错误及查找百度后,需要使用docker-php-ext-configure命令配置

docker-php-ext-configure zip --with-zlib-dir=/usr

...
configure: error: Can not find zlib headers under "/usr"

上面的操作是行不通,还是一步步安装吧;为啥/usr/src/php/ext下存在zlib zip拓展,缺无法安装呢,为啥不把完整依赖携带呢?
/usr/src/php/ext目录下的内容zip其实只是为了支持在php中有相关压缩的函数接口,而这些拓展的php函数本身是没有相关拓展功能的,最终还是得调取真正的zip库。拓展只是用php封装了相关的接口罢了

apt-get update
# 安装zip扩展所需的依赖扩展
apt-get install -y --no-install-recommends zlib1g-dev && apt-get install -y --no-install-recommends libzip-dev
apt-get clean
# rm -rf /var/cache/apk/* && rm -rf /var/lib/apt/lists/* && apt-get autoremove
docker-php-ext-install zip

注意默认比较慢,可以修改为国内镜像源

#apt-get源 使用阿里的源
RUN sed -i s@/deb.debian.org/@/mirrors.aliyun.com/@g /etc/apt/sources.list

安装redis拓展模块

curl -L -o /tmp/redis.tar.gz https://codeload.github.com/phpredis/phpredis/tar.gz/5.0.2
tar -xfz /tmp/redis.tar.gz
rm -r /tmp/redis.tar.gz
mkdir -p /usr/src/php/ext
mv phpredis-5.0.2 /usr/src/php/ext/redis
docker-php-ext-install redis

 类似资料: