zlib gzopen / gzopen64 issue with PHP on Ubuntu 9.10 Karmic

Hi there,

I have Ubuntu 9.10 (not 64bit) running with a basic LAMP stack (configured per the "Setting up a LAMP Server on Ubuntu 9.10 (Karmic)" guide on the Linode library), and a site running WordPress. The auto-upgrading function of WP is having some trouble, claiming that the zlib extension is missing - but it's not, it's definitely present and enabled.

I had a look at the actual code which was causing the problem, and it's checking whether the gzopen() function exists. Sure enough, PHP is reporting that gzopen() doesn't exist or isn't defined. Very odd. gzopen64() however does exist. This surprises me quite a bit, since plenty of PHP web apps use gzopen().

Does anyone have a suggestion as to how I can fix this? I've already tweaked the specific WordPress file (wp-admin/includes/class-pclzip.php) to use gzopen64() instead, and that allows the auto-upgrade functionality to work just fine, but it's not a long-term solution. For one thing, every auto-upgrade naturally replaces that file, so the same thing will happen next time.

I've googled around a bit and noticed plenty of tickets filed against Karmic when it was in beta, but nothing really definitive to solve the issue. This Karmic ticket mentions it's fixed in karmic-proposed, so I added

deb http://us.archive.ubuntu.com/ubuntu/ karmic-proposed restricted main multiverse universe

to my /etc/apt/sources.list then did an apt-get update and apt-get upgrade, restarted Apache, but I'm still seeing the issue. Any advice would be appreciated!

2 Replies

Fixed now. There's an updated version of the php5 package which fixes this, but it won't be picked up by the standard apt sources file, so I wasn't seeing it. To fix the issue, do this:

1. Edit your /etc/apt/sources.list file and add this line at the bottom:

deb http://us.archive.ubuntu.com/ubuntu/ karmic-updates main restricted

You can change the "us." part to whatever mirror is best for you, but US should work great for Linode. You should then update apt's packages list by issuing the following command:

apt-get update

2. Now we need to get the new version of PHP (it's version "5.2.10.dfsg.1-2ubuntu6.1" specifically). Issue this command, and if it asks you to confirm just type Y and hit return:

apt-get install php5

3. Finally, we need to restart Apache to use the new version of PHP. Issue this command:

/etc/init.d/apache2 restart

That's it. Your zlib-related PHP functions like WordPress auto-upgrading should work fine now. You can test it on the command line too:

php -r 'var_dump(function_exists("gzopen"));'

If it worked, you'll see:

bool(true)

Hope that helps someone.

If you're using fastcgi instead of mod_php, please don't make the mistake of forgetting to restart your php-cgi processes!

I spent way too long trying to figure out why I was still getting this error despite having upgraded, and despite the fact that from the command line, var_dump(function_exists("gzopen")) worked just fine (using both php and php-cgi)!

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct