I'm getting the error "Class 'ZipArchive' not found" even after php-zip install and apache restart. I'm currently running the project on Ubuntu 20.04
Asked
Active
Viewed 205 times
0
-
what is the output of the following comamnds? `php -v` `php -m` `dpkg --get-selections | grep -i php` – Rakesh Mehta Sep 23 '22 at 14:26
-
Does this answer your question? [Fatal error: Class 'ZipArchive' not found in](https://stackoverflow.com/questions/3872555/fatal-error-class-ziparchive-not-found-in) – N69S Sep 23 '22 at 14:28
-
@RakeshMehta 'm running on php 7.4. When i run php -m, i can see that zip is installed. When i run the 3rd command, i can see php7.4-zip – Vic Sep 23 '22 at 14:33
-
What does your phpinfo() say? Don't see ziparchive there? Try removing and purging php7.4-zip and install again using apt – Rakesh Mehta Sep 23 '22 at 14:33
-
@RakeshMehta From php -i, i can see Zip=> enabled Zip version => 1.15.6. I installed the current version with apt through apt-get install php7.4 – Vic Sep 23 '22 at 14:37
-
@RakeshMehta i have realized that when i run php(info) in the browser, i cannot see the Zip module enabled. However, when i type in php -i, i can see that it's enabled. Could my Laravel application be using a different php version and the terminal references a different version? – Vic Sep 23 '22 at 15:23
-
No, that is definitely not laravel. When you run php from cli the environment differs compared to when you run it as cgi or fast-cgi. It seems like apache is not loading the required library. From which repo did you install php7.4, was it from ondrej or official ubuntu repo? – Rakesh Mehta Sep 23 '22 at 15:54
1 Answers
2
Probably you are running php as an apache module using libapache2-mod-php7.4, try to switch over to fpm by installing php7.4-fpm and libapache2-mod-fcgid.
Apache won't load a module / library if there is a version incompatibility and probably this is happening with your installation.
It should solve your problem. This article will guide you through the installation of php-fpm
Though it is for ubuntu 18, but same will work on ubuntu.
Note PHP-FPM will speed up your web application as well.

Rakesh Mehta
- 519
- 2
- 9