使用php扩展包安装工具pecl,但是有个问题是需要离线安装,先去php官网下载需要安装的扩展库
扩展库下载地址:
https://pecl.php.net/ 先搜索,再下载,本次需要安装的是zip扩展,下载的包为zip-1.21.1.tgz
#解压之后会有一个package.xml文件,将他复制到zip-1.21.1内
yunwei@YunweideMacBook-Pro Downloads % tar -xvf zip-1.21.1.tgz
yunwei@YunweideMacBook-Pro Downloads % ls
package.xml
zip-1.21.1
zip-1.21.1.tgz
yunwei@YunweideMacBook-Pro Downloads % cp package.xml zip-1.21.1
#开始安装zip
yunwei@YunweideMacBook-Pro Downloads % cd zip-1.21.1
yunwei@YunweideMacBook-Pro zip-1.21.1 % sudo /Applications/MxSrvs/bin/php_/bin/pecl install ./package.xml
如果出现类似这样的信息说明安装成功了
Build process completed successfully
Installing '/Applications/MxSrvs/bin/php/lib/php/extensions/no-debug-non-zts-20170718/zip.so'
install ok: channel://pecl.php.net/zip-1.21.1
configuration option "php_ini" is not set to php.ini location
You should add "extension=zip.so" to php.ini
zip.so文件会保存在默认的扩展库目录
yunwei@YunweideMacBook-Pro ext % pwd /Applications/MxSrvs/bin/php/ext yunwei@YunweideMacBook-Pro ext % ls redis.so xdebug.so zip.so yunwei@YunweideMacBook-Pro ext % #修改php.ini文件,在php.ini文件中加入 extension=zip.so
重启php
可能遇到的问题
autoconf不存在,需要重新安装libzip等等,可以使用brew安装
#安装brew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
#安装autoconf
brew install autoconf
#安装libzip
brew install libzip