php的zip扩展 先装libzip

【宝塔面板】php7.4 安装 zip 扩展 - PHP笔记网

在CentOS 7系统中,通过【宝塔Linux】安装了PHP7.4,运行业务系统时,报错:

|---|------------------------------------------------------------------------------|
| 1 | it is missing from your system. Install or ``enable PHP's zip extension. |

提示需要php的zip扩展,但是在后台面板中,又没有找到zip扩展,不然的话,可以直接点击安装:

其实在PHP安装包下面,已经有了这个扩展,进入目录,直接安装:

1、提前建立好常用的软链接:

|-------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 1 2 3 4 5 6 7 8 9 | rm -rf ``/usr/local/bin/php rm -rf ``/usr/local/bin/phpize rm -rf ``/usr/local/bin/php-config rm -rf ``/usr/local/bin/composer ln -sf ``/www/server/php/74/bin/php /usr/local/bin/php ln -sf ``/www/server/php/74/bin/phpize /usr/local/bin/phpize ln -sf ``/www/server/php/74/bin/php-config /usr/local/bin/php-config ln -sf ``/www/server/php/74/bin/composer /usr/local/bin/composer |

2、进入PHP源码目录的ext文件夹,安装zip扩展

|-----|-------------------------------------------------------|
| 1 2 | cd /www/server/php/74/src/ext/zip .``/configure |

报错:

|----------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 1 2 3 4 5 6 7 8 9 10 11 12 | checking ``for zip archive ``read``/write support... ``yes``, shared checking ``for libzip >= 0.11... no configure: error: Package requirements (libzip >= 0.11) were not met: Requested ``'libzip >= 0.11' but version of libzip is 0.10.1 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. |

3、按照提示,升级 libzip

先删除原有的libzip

|---|------------------------|
| 1 | yum remove -y libzip |

下载并手动编译安装, 自己下载到合适的位置

|---|--------------------------------------------------------------|
| 1 | wget https:``//nih``.at``/libzip/libzip-1``.2.0.``tar``.gz |

解压

|---|---------------------------------------|
| 1 | tar -zxvf libzip-1.2.0.``tar``.gz |

进入到源码目录

|---|---------------------|
| 1 | cd libzip-1.2.0 |

配置

|---|-----------------|
| 1 | .``/configure |

编译并安装

|---|------------------------|
| 1 | make && make install |

更新依赖路径,CentOS版本小于8的,一定要执行下面这个命令,不然还是找不到 libzip

|---|----------------------------------------------------------|
| 1 | export PKG_CONFIG_PATH=``"/usr/local/lib/pkgconfig/" |

重新编译 php zip扩展

|-------|------------------------------------------------------------------------------------|
| 1 2 3 | cd /www/server/php/74/src/ext/zip .``/configure make && ``make install |

编译正常

在 php.ini 中,配置扩展

|---|------------------------------------------|
| 1 | vim ``/www/server/php/74/etc/php``.ini |

增加配置:

|---|-----------------|
| 1 | extension=zip |

重启php-fpm

(可以到 宝塔后台去重启)

相关推荐
AI 智能服务10 小时前
第6课__本地工具调用(文件操作)
服务器·人工智能·windows·php
松涛和鸣13 小时前
49、智能电源箱项目技术栈解析
服务器·c语言·开发语言·http·html·php
晚枫歌F13 小时前
io_uring的介绍和实现
开发语言·php
Tisfy16 小时前
网站访问耗时优化 - 从数十秒到几百毫秒的“零成本”优化过程
服务器·开发语言·性能优化·php·网站·建站
xifangge202517 小时前
PHP 错误日志在哪里看?Apache / Nginx / PHP-FPM 一次讲清
nginx·php·apache
ShoreKiten19 小时前
ctfshow-web257【保姆级wp】
php·web
chilavert31821 小时前
技术演进中的开发沉思-303计算机原理:加密基础
开发语言·算法·php·计算机原理
AC赳赳老秦1 天前
DeepSeek 私有化部署避坑指南:敏感数据本地化处理与合规性检测详解
大数据·开发语言·数据库·人工智能·自动化·php·deepseek
桃花键神2 天前
Undetectable接入亮数据代理IP深度测评:高效、稳定、适配性极强的海外多账号运营利器
网络协议·tcp/ip·php
catchadmin2 天前
PHP 8.5 #[\NoDiscard] 揪出“忽略返回值“的 Bug
php