These were notes from an attempt to get JSON support included for a custom compiled version of PHP 5.1.6. Doesn’t seem to work as expected. Notes are here for reference just in case I need to revisit this process at some point.
Get the Pear
First, install JSON via Pecl like this:
sudo pecl install json
You might get a warning that reads like this:
WARNING: "pear/json" is deprecated in favor of "channel://http://www.php.net/json/json"
Just ignore it. The warning is correct in that newer version of PHP have JSON support built-in, but we are dealing with adding JSON support to an ancient version of PHP so this is what we got to do.
Finding where the Pear
json-1.2.1.tgz archive was downloaded to.
Now the tricky part is finding the exact path the
json-1.2.1.tgz. In some cases it will be installed in a directory like this:
In others it will be installed in a directory like this:
php5-yIoy8f/ directory name is a hash so it might change on each install. So it’s sometimes best to just run a
find command like this to find the full path of the file:
find /build -type f -name "json-1.2.1.tgz"
If you forget
find syntax like I do sometimes, this combo command with output piped to
grep works just as well:
find /build | grep json-1.2.1.tgz
Or you can just update the
locate database like this:
And the just run this command:
Which would return something like this:
So just go into that directory like this and follow the rest of the steps:
Compiling and installing the extension.
Next, decompress the archive like this:
sudo tar -xvf ./json-1.2.1.tgz
Now go into the decompressed directory:
phpize command on the code like this:
sudo /opt/php516-gd/bin/phpize json
configure process completes, run
Finally install it by running
sudo make install:
sudo make install