Home >Backend Development >PHP Tutorial >Why is my PHP script throwing a \'Class \'ZipArchive\' not found\' error on my Linux server?

Why is my PHP script throwing a \'Class \'ZipArchive\' not found\' error on my Linux server?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-11-26 21:12:12862browse

Why is my PHP script throwing a

ZipArchive Class Not Found Error on Linux Server

Hosting a PHP script that utilizes the ZipArchive class can result in the dreaded "Fatal error: Class 'ZipArchive' not found" message. This error occurs when PHP does not have the zip extension installed, which is necessary for working with zip archives.

Resolution: Install the Zip Extension

To resolve this issue, ensure that the zip extension is installed in PHP. The specific steps for installation vary depending on your operating system and PHP version.

For Linux systems such as Debian and Ubuntu, follow these steps:

  1. Update your package lists:

    sudo apt update
  2. Install the PHP zip extension:

    sudo apt install php-zip
  3. Restart your webserver to apply the changes:

    sudo systemctl restart apache2

Once the zip extension is installed and the webserver is restarted, your PHP script should be able to access the ZipArchive class without errors.

The above is the detailed content of Why is my PHP script throwing a \'Class \'ZipArchive\' not found\' error on my Linux server?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn