The error "ZIP extension needs to be loaded for OpenCart to work!" appears when PHP's Zip extension is missing or not enabled. OpenCart uses the Zip extension to handle file compression, module installations, and backups.
First, verify whether the ZIP extension is already present on your system.
php -m | grep zip
Interpretation:
zip in the output, the extension is installed but might not be enabled for your web server's PHP configuration.Also check your PHP version to ensure you install the correct package:
php -v
The installation command varies based on your operating system and PHP version.
# Update package list
sudo apt update
# Install ZIP extension for default PHP version
sudo apt install php-zip -y
For specific PHP versions:
# For PHP 7.4
sudo apt install php7.4-zip -y
# For PHP 8.0
sudo apt install php8.0-zip -y
# For PHP 8.1
sudo apt install php8.1-zip -y
# For PHP 8.2
sudo apt install php8.2-zip -y
# Install ZIP extension for default PHP version
sudo yum install php-zip -y
If using Remi repository (recommended for specific PHP versions):
# For PHP 7.4
sudo yum install php74-php-zip -y
# For PHP 8.0
sudo yum install php80-php-zip -y
# For PHP 8.1
sudo yum install php81-php-zip -y
# For PHP 8.2
sudo yum install php82-php-zip -y
php -v for CLI and create a phpinfo() file for web server PHP version.
If the ZIP extension is installed but not being loaded, you need to enable it in the appropriate php.ini file.
The web server may use a different php.ini than the command line. First, identify which configuration file is relevant:
# For command-line PHP
php --ini | grep "Loaded Configuration File"
# For web server PHP (common locations)
sudo find /etc -name "php.ini" | grep -E "(apache2|fpm|cli)"
Open the appropriate configuration file based on your web server:
# For Apache on Ubuntu/Debian
sudo nano /etc/php/7.4/apache2/php.ini
# For PHP-FPM (Nginx) on Ubuntu/Debian
sudo nano /etc/php/7.4/fpm/php.ini
# For CentOS/RHEL (common location)
sudo nano /etc/php.ini
Look for the ZIP extension line (search with Ctrl+W for "zip"):
;extension=zip
Remove the semicolon (;) at the beginning to uncomment the line:
extension=zip
If the line doesn't exist, add it to the extensions section (usually near other extension= lines). Save the file (Ctrl+O, Enter, Ctrl+X).
Configuration changes only take effect after restarting your web server and PHP processor.
# For Apache
sudo systemctl restart apache2
# For Nginx with PHP-FPM
sudo systemctl restart php7.4-fpm # Adjust version as needed
sudo systemctl restart nginx
# For CentOS/RHEL Apache
sudo systemctl restart httpd
After restarting services, verify the ZIP extension is now active.
# Check command-line PHP
php -m | grep zip
# Create a quick test to verify web server PHP
echo "<?php echo extension_loaded('zip') ? 'ZIP enabled' : 'ZIP NOT enabled'; ?>" | sudo tee /var/www/html/zip_test.php
Visit http://yourdomain.com/zip_test.php in your browser. It should display "ZIP enabled".
sudo rm /var/www/html/zip_test.php
If ZIP still doesn't appear, check your web server error logs and ensure you modified the correct php.ini file for your web server (not just CLI).
Finally, verify the fix works within OpenCart itself.
If the ZIP extension is properly installed and enabled, OpenCart should no longer display the error and should be able to handle compressed files normally.
| Issue | Fix |
|---|---|
| ZIP extension missing | sudo apt install php-zip (Ubuntu) or sudo yum install php-zip (CentOS) |
| ZIP installed but not enabled | Uncomment extension=zip in the correct php.ini file |
| Changes not applied | Restart Apache/PHP-FPM: sudo systemctl restart apache2 |
| Wrong PHP version package | Install version-specific package: php7.4-zip, php8.0-zip, etc. |
| Still not working | Verify correct php.ini file and check web server error logs |
Following these steps will resolve the "ZIP extension needs to be loaded" error, allowing OpenCart to properly handle module installations and file operations!