環(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
命令時遇到:
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
報錯:沒有權(quán)限(即便加了sudo)
ln: /usr/include: Operation not permitted
解決方法:
1、重啟mac電腦,同時按住command+r, 出現(xiàn)進(jìn)度條再松開。
2、彈出界面,選擇“實用工具->終端”,輸入:csrutil disable,然后回車會有英文提示成功。
3、重新啟動電腦
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
命令,報錯:
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版本,因為更高版本安裝時,還需要另外安裝cmake
命令。
接著執(zhí)行phpize
命令
當(dāng)執(zhí)行 make
命令時:
/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
命令
最后返回一個地址:這個地址下保存了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
這個zip模塊就安裝完成了