pclzip.lib.php : Missing zlib extensions

This problem took me awhile to solve, and required a bit of digging, so I’m going to post my solution here, in hopes that it helps anyone with the same problem. After upgrading my VPS from Ubuntu 12.04 LTS to 14.04 LTS, I got pclzip.lib.php : Missing zlib extensions on a bunch of my PHP scripts.

Background

I recently upgraded my VPS running Ubuntu 12.04 to Ubuntu 14.04. Every package on the system got a new version – including PHP and Apache – my prime suspects as the culprit of this error.

The Problem

The problem, is this error: pclzip.lib.php : Missing zlib extensions. Cryptic, right? It stops any script in it’s tracks, and leaves no errors in any logs.

I did a bunch of research, and discovered that on 32-bit 14.04 (Trusty) systems, PHP is compiled with large file support. In this version of PHP, this also means that gzopen is removed, and gzopen64 is exposed instead.

The Solution

Arduous, I’m afraid. You’re going to need to redefine gzopen in any PHP scripts that use the function. Fortunately, it’s not too hard – just pop this code in (assuming your code is organized sanely) an include file (code courtesy of the Piwik team, that’s where I got it from!):

3 Replies to “pclzip.lib.php : Missing zlib extensions”

  1. Thanks very much for taking the time to research this solution! I have a WordPress with WooCommerce install on an Ubuntu/nginx VPS from Digitalocean. I was getting the missing gzopen() error in the Woo system status page.

    I put this code in my child theme’s functions.php file, and now no more missing function. Thanks again! 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.