skip to Main Content

I’m running php7 on a redhat machine and am getting the following error in laravel:

Class 'ZipArchive' not found

I had this issue on my personal virtual machine server and all I had to do was run:

sudo yum install php7.0-zip

On my dev server I tried running the command and I get:

sudo yum install php7.0-zip
Loaded plugins: product-id, search-disabled-repos, subscription-manager
No package php7.0-zip available.

Just for more information here is my php version:

php -v
PHP 7.1.12 (cli) (built: Dec  1 2017 13:53:12) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies

Edit: If I run php7.1-zip

sudo yum install php7.1-zip
Loaded plugins: product-id, search-disabled-repos, subscription-manager
epel/x86_64/metalink                                     |  16 kB     00:00     
gitlab_gitlab-ee/x86_64/signature                        |  836 B     00:00     
gitlab_gitlab-ee/x86_64/signature                        | 1.0 kB     00:00 !!! 
gitlab_gitlab-ee-source/signature                        |  836 B     00:00     
gitlab_gitlab-ee-source/signature                        |  951 B     00:00 !!! 
icinga-stable-release                                    | 2.5 kB     00:00     
jenkins                                                  | 2.9 kB     00:00     
plesk-php-5.6                                            | 2.9 kB     00:00     
plesk-php-7.0                                            | 2.9 kB     00:00     
remi-php71                                               | 2.9 kB     00:00     
remi-safe                                                | 2.9 kB     00:00     
(1/2): remi-php71/primary_db                               | 208 kB   00:00     
(2/2): remi-safe/primary_db                                | 1.1 MB   00:01     
No package php7.1-zip available.
Error: Nothing to do

5

Answers


  1. Perhaps you can try to install php7.1-zip or php-zip packages…

    Login or Signup to reply.
  2. As you are using some plesk package, this is not really a RHEL/CentOS server.

    What is the package name providing the php command ?

    rpm -qf $(which php)
    
    • If php-cli-7.1.12 (from remi-php71), you need php-pecl-zip from the
      same repository
    • If php71-php-cli-7.1.12 (from remi-safe, SCL package) you
      need php71-php-pecl-zip from the same repository

    General rule, for any foo extension yum install package_namespace-foo should work, as explained by the Wizard.

    Login or Signup to reply.
  3. I had the same problem. I was getting:

    No package php7.0-zip available.
    Error: Nothing to do

    when running

    yum install php7.0-zip
    

    I first searched all yum packages by running:

    yum search php70-zip
    

    if returns nothing then run :

    yum search php70-php-zip
    

    if returned:

    php70-zip.x86_64 : ZIP archive management extension for PHP

    Then I installed the package that the search told me was there:

    yum install php70-zip.x86_64
    

    The installation worked like a charm. Then I restarted my apache server.

    service httpd restart
    

    Now php zip (for php7) is installed!

    Login or Signup to reply.
  4. I know is an old thread, but I faced same problem on CENTOS, and I solved similar (but quite different way):

    yum search php70-zip
    

    No Matches found

    yum search php70-php-zip 
    

    found this

    ea-php70-php-zip.x86_64 : A module for PHP applications that need to handle .z
                        : files
    

    then

    sudo yum install ea-php70-php-zip.x86_64
    

    and it was successfully installed

    after that I restarted apache

    sudo /etc/init.d/httpd restart
    

    and problem was solved

    I took me a lot of time, because I did not know package name, difficult for me, I found that on web: ea-php70-php-zip.x86_64

    Login or Signup to reply.
  5. I had the same problem for PHP 7.1. I learned about yum search on the zip package:

    $ yum --enablerepo=remi-php71 search php71 | grep zip
    php71-php-pecl-zip.x86_64 : A ZIP archive management extension
    

    I installed it:

    $ sudo yum --enablerepo=remi-php71 install php71-php-pecl-zip
    

    For some reason, the files zip.so and zip.ini were missing in /usr/lib64/php/modules and /etc/php.d/ directories respectively. So I copied them:

    $ sudo cp /opt/remi/php71/root/usr/lib64/php/modules/zip.so /usr/lib64/php/modules/zip.so
    $ sudo cp /etc/opt/remi/php71/php.d/40-zip.ini /etc/php.d/40-zip.ini
    

    Finally, I restarted the services

    $ sudo systemctl restart  php-fpm nginx
    

    And I can see that zip is loaded:

    $ php -m
    [PHP Modules]
    bz2
    calendar
    ...
    zip
    zlib
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search