Articles on websites & etc.

§ Home > Index > Linux and FreeBSD

Upgrading a PHP PECL extension under FreeBSD

Notes for installing and upgrading a PHP PECL extension under FreeBSD.

	System: FreeBSD 4.7 Release
	PHP: 4.4.2
	pecl zip1.2.1 (original)
	pecl zip1.3.1 (new)

At first, no PECL package for the zip extension was installed.
To install it, I first tried via php-extensions, but this
	turned out to be unnecessary. FWIW, the commands were:
	cd /usr/ports/lang/php4-extensions
	make config (then select packages)
	make install clean
Newly built extensions were installed in:
The existing extensions were in:
So, I changed php.ini extension_dir setting to:
	extension_dir = /usr/local/lib/php/20020429/
This was not necessary because it installed an old, buggy version of the zip extension.
	Later, changed back to original extension_dir and added line:

When using the old zip 1.2.1 extension, I found bug and posted it on PHP bugs as
	"zip_entry_read handling of null byte"
Turned out this bug was fixed in version 1.2.3 of the extension, found here: as described in the Changelog

So, I needed to update my installation of, 
	which turned out to be a mega-pain in the butt.

First, I tried to download, 
	unzip, and make install it.  However, this is just a base set, which
	only has the source files and package.xml description file.

Trying "pkg_add zip-1.3.1.tgz" gave the following error:
	tar: +CONTENTS: Not found in archive
	tar: Error exit delayed from previous errors
	pkg_add: tar extract of /home/me/test/zip-1.3.1.tgz failed!
	pkg_add: unable to extract table of contents file from '/home/me/test/zip-1.3.1.tgz' - not a package?

This happened because the .tgz is a PEAR package, not a FreeBSD package.
	(BTW, usually, the above error is seen when the FreeBSD package .tgz is corrupt,
		perhaps because it was downloaded as ascii instead of binary.)

To install it, I had to run:
	pear install

But this gave the error:
	Cannot find autoconf. Please check your autoconf
	installation and the $PHP_AUTOCONF environment
	variable is set correctly and then rerun this script. 
	ERROR: `phpize' failed".

To install autoconf, I went to FreeBSD ports collection for 4-stable:

I confirmed that it was not already installed by running "pkg_info".
Running pkg_add gnu-autoconf-2.59.tgz did not work because the 
	default download location for pkg_add was out of date.

It finally worked by running a command like:
pkg_add -r

I also ran this for gnu-automake and gnu-libtool.

After installing autoconf, when running pear install, the same error occurred.
Checking in /usr/local/bin showed autoconf5xx binaries, but no autoconf.
So, I created a symbolic link /usr/local/bin/autoconf to the highest numbered binary.
I did the same for the "autoheader" command for good measure.
	Logged out and back in for new symbolic links to be recognized in the path.

Finally, the above pear install worked.
The new file appeared in the current extensions directory.
Added to /usr/local/lib/php.ini and 
	then did "apachectl graceful" to restart apache.

From the bug report, sample code for the zip extension:
Note, the "dl" line to load the extension was not required 
	after putting the extension line in php.ini and restarting apache.

Reproduce code:
// contains one file with a null byte in the middle
$zipfile = zip_open("");
$zipentry = zip_read($zipfile);
zip_entry_open($zipfile, $zipentry);

$content = zip_entry_read($zipentry, zip_entry_filesize($zipentry));
print "filesize: ".filesize("onejpg.jpg")."\n";
print "variable: ";



To download and onejpg.jpg, go here:

Created 2006-05-06, Last Modified 2011-07-24, © Shailesh N. Humbad
Disclaimer: This content is provided as-is. The information may be incorrect.