環(huán)境:
Mac os cataline 版本 10.15.3 (19D76)
PHP Version 7.3.11
資源:libzip-1.2.0.tar.gz+zip 提取碼: vk6v
安裝ZipArchive
wget [http://pecl.php.net/get/zip](http://pecl.php.net/get/zip)
tar -zxvf zip
cd zip-1.x.x
phpize
./configure
make
sudo make instal
執(zhí)行 phpize
命令時(shí)遇到:
usermac@ usermac zip-1.17.1 % phpize
grep: /usr/include/php/main/php.h: No such file or directory
grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:
終端
cd /usr
/usr
下找不到include
文件
Xcode:(如果找不到Xcode.app,先到App Store下載安裝)
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include
路徑下有需要的文件属愤,最好自己cd到路徑下查看MacOSX10.15.sdk
可能不一樣屉栓。
直接在終端執(zhí)行
sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include /usr/include
報(bào)錯(cuò):沒有權(quán)限(即便加了sudo)
ln: /usr/include: Operation not permitted
解決方法:
1窗声、重啟mac電腦,同時(shí)按住command+r, 出現(xiàn)進(jìn)度條再松開。
2伟件、彈出界面笛钝,選擇“實(shí)用工具->終端”,輸入:csrutil disable聪富,然后回車會(huì)有英文提示成功莺丑。
3、重新啟動(dòng)電腦
4善涨、進(jìn)入“終端”窒盐,輸入
cd /usr
sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include /usr/include
提示:系統(tǒng)文件只讀
ln: /usr/include: Read-only file system
終端執(zhí)行:
sudo mount -uw /
然后再執(zhí)行第4步草则。
查看/usr/下文件,操作完成蟹漓。
接著執(zhí)行phpize
命令炕横,報(bào)錯(cuò):
checking for libzip... not found
configure: error: Please reinstall the libzip distribution
需要安裝libzip
wget https://libzip.org/download/libzip-1.2.0.tar.gz
tar -zxvf libzip-1.2.0.tar.gz
cd libzip-1.2.0
./configure
make
sudo make install
之所以下載1.2.0版本,因?yàn)楦甙姹景惭b時(shí)葡粒,還需要另外安裝cmake
命令份殿。
接著執(zhí)行phpize
命令
當(dāng)執(zhí)行 make
命令時(shí):
/usr/local/include/zip.h:59:10: fatal error: 'zipconf.h' file not found
#include <zipconf.h>
^~~~~~~~~~~
1 error generated.
make: *** [php73/php_zip.lo] Error 1
將zipconf.h
拷貝過去
cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h
接著執(zhí)行 make && sudo make install
命令
最后返回一個(gè)地址:這個(gè)地址下保存了zip.so
Installing shared extensions: /usr/lib/php/extensions/no-debug-non-zts-20180731/
編輯/etc/php.ini
(可以通過phpinfo()來查看位置)
將zlib.output_compression = Off
改為 zlib.output_compression = On
;
增加extension =/usr/lib/php/extensions/no-debug-non-zts-20180731/zip.so
保存
最后重啟一下Apache
sudo apachectl restart
這個(gè)zip模塊就安裝完成了
參考:
PHP如何開啟自帶的ZipArchive類,實(shí)現(xiàn)壓縮解壓功能
PHP ZipArchive 安裝