Linux 環境上傳 Excel 檔案 (OOXML 格式本質為 ZIP) 時拋出 ZipArchive library is not enabled 錯誤。Windows 下只需啟用 php_zip.dll,Linux 需手動編譯安裝 PHP zip 擴展模組。
cd /usr/src
wget https://pecl.php.net/get/zip
tar zxvf zip-1.x.x.tgz # 實際檔名依下載版本
cd zip-1.x.x
/usr/bin/phpize # 確認 phpize 路徑:find / -name phpize
./configure --with-php-config=/usr/bin/php-config # 確認 php-config 路徑
make
make install
/usr/lib/php/modules/zip.so)php.ini:
extension=zip.so
zlib.output_compression = On # 原為 Off 改為 On
./apachectl restartphp.ini:extension=php_zip.dll 取消註解zlib.output_compression = On建立測試腳本 搜尋 zip 區塊確認已載入,或直接實例化 new ZipArchive() 測試。