錯誤:Class 'ZipArchive' not found。
解決方法:安裝一個PHP擴展即可。
依次執行下面的命令:
cd ~
wget http://pecl.php.net/get/zip
tar -zxvf zip
cd zip-x.x.x
phpize
./configure
make
make install
安裝過程中可能會出現的問題:
- Cannot find php-config. Please use --with-php-config=PATH
服務器上存在多個php版本,手動指定php-config文件即可:
./configure --with-php-config=/www/server/php/73/bin/php-config
- Please reinstall the libzip distribution
libzip版本過低,按照下面步驟重新安裝:
cd ~
yum remove libzip
wget https://nih.at/libzip/libzip-xxx.tar.gz
tar -zxvf libzip-xxx.tar.gz
cd libzip-xxx
./configure
make & make install
- fatal error: zipconf.h: No such file or directory
找不到zipconf.h文件,執行下面命令后重試:
find /usr/local -iname 'zipconf.h'
ln -s /usr/local/lib/libzip/include/zipconf.h /usr/local/include
成功安裝zip之后會返回一個路徑:
Installing shared extensions: /www/server/php/73/lib/php/extensions/no-debug-non-zts-20180731/
加到php.ini中:
extension=/www/server/php/73/lib/php/extensions/no-debug-non-zts-20180731/zip.so
重啟php,搞定