简体   繁体   中英

ZipArchive not found but appears to be installed (PHP 7.2)

I'm installing a CMS that requires ZipArchive on an Amazon EC2 instance (Amazon Linux 2). The requirements wizard says ZipArchive is not supported:

在此处输入图片说明

But if I try to install ZipArchive as per instructions I've found online, the server tells me it's already installed:

[ec2-user@ip-***-**-**-** ~]$ sudo yum install php-zip
Loaded plugins: langpacks, priorities, update-motd
amzn2-core                                                                                                                                                                         | 2.0 kB  00:00:00     
Package matching php-common-5.4.16-43.amzn2.0.1.x86_64 already installed. Checking for update.
Nothing to do

I have restarted the httpd service.

I have also tried:

[ec2-user@ip-***-**-**-** ~]$ sudo yum install php7.0-zip
Loaded plugins: langpacks, priorities, update-motd
amzn2-core                                                                                                                                                                         | 2.0 kB  00:00:00     
No package php7.0-zip available.
Error: Nothing to do

I have also tried adding:

extension=zip.so

To php.ini and restarted the httpd service. Still no joy.

In the PHP manual for ZipArchive it says "In order to use these functions you must compile PHP with zip support by using the --enable-zip configure option." I'm not sure where or when to do this. I have simply used:

yum install php php-mysql

To install PHP.

Almost a day trying to work this out and I'm at a loss as to where to go from here. Can somebody point me in the right direction?

If you are using Remi's repo, I noticed the zip module is a pecl extension, so to install and enable zip run

 sudo yum -y install php-pecl-zip

Then restart php-fpm is you are using NGINX or restart APACHE

 sudo service php-fpm restart
 sudo service httpd restart

You can install Remi repo

**RHEL or CentOS**
yum install yum-utils
yum-config-manager --enable remi-php72

See instructions on Remi Repo

I had the same problem (Amazon Linux 2 AMI) trying to install Laravel. The problem is that this AMI uses libzip 0.10.1 while at least 0.11 is required, and if you check in your extension folder (in this AMI: /usr/lib64/php/modules), the file zip.so is missing. So, if you enable the extension in your php.ini file, you'll get an error in apache's log. I solved the issue using Remi's RPM repository to install libzip 1.1.3. This is what I did:

  1. install epel repo (needed to install Remi's RPM)
  2. install Remi's repo
  3. install libzip from the repo. You can check the new libzip version, ie:

     $ yum list "*libzip*" Installed Packages libzip-last.x86_64 1.1.3-1.el7.remi installed 
  4. Now that you have a compatible libzip, you can compile the zip extension: download the package from PECL in your tmp folder, extract the files and from the package root:

     $ sudo phpize $ sudo ./configure $ sudo make $ sudo make install 
  5. after the make install command, the output should be:

     Installing shared extensions: /usr/lib64/php/modules/ 

    and if you go in that dir, now you should finally see the zip.so file.

  6. Change your php.ini adding

     extension=zip 
  7. Restart webserver and check your php info. This is what I see in mine:

     Zip enabled Zip version 1.15.2 Libzip version 0.11.2 

In my case I was able to install laravel.

I had a similar issue on Centos 7 and PHP 7.3.
I was able to resolve it with:

sudo yum install php-pecl-zip.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM