zlib gzopen / gzopen64 issue with PHP on Ubuntu 9.10 Karmic
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
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
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.
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)!