Solution to PHP error ZipArchive library is not enabled

Source: Internet
Author: User

Today, when uploading an Excel file under Linux, an error "ZipArchive library is not enabled" is thrown. While the code on my local windows server runs normally.
 
The reason is: In Linux, there is no php_zip.dll file (or it will not work), so you need to re-compile the php zip module.
    
Solution in Unix/Linux:
  
1. Run the following commands in sequence:

Cd/usr/src wget http://pecl.php.net/get/zip (the latest version will be downloaded online by default) tar zxvf zip. x. x. tgz (downloaded package name) cd zip-1.x.x/usr/bin/phpize (corresponding phpize path find/-name phpize out result/usr/bin/phpize ). /configure -- with-php-config =/usr/bin/php-config (corresponding php-config path) make instal


 
2. View the generated module path (after installation, the location of zip. so will be displayed on the screen ):
Cd/usr/lib/php/modules/(corresponding extensions path/usr/lib/php/modules /)
 
3. Modify php. ini
Added extension = zip. so
Then change zlib. output_compression = Off to zlib. output_compression = On in the php. Ini file;
 
4. restart Apache:./apachectl restart;
    
The zip module for php is installed and the ZipArchive class can be used in php.
 
Note: the solution in Windows is relatively simple:
 
1. In the php. Ini file, remove the semicolon ";" Before extension = php_zip.dll.
Then change zlib. output_compression = Off to zlib. output_compression = On in the php. Ini file;
 
2. Restart the Apache server.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.