Question

I'm using Ubuntu 12.04 LTS and needed PHP 5.4 so I'm using Ondřej Surý's (php5-oldstable) package.

Both phpinfo and the CLI show that JSON is enabled:

#php -i | grep -i json
json
json support => enabled
json version => 1.2.1

My application mostly works. But periodically (approx one page refresh in ten) there is a PHP error. This only happens intermittently.

 PHP Startup: Unable to load dynamic library '/usr/lib/php5/20100525+lfs/json.so'
 - /usr/lib/php5/20100525+lfs/json.so: cannot open shared object file: 
 No such file or directory "json.so"

How do I fix this?

Was it helpful?

Solution

I think that possible culprit (as I have answered in email) is that you are loading json extension somewhere from the configuration file.

The JSON extension is compiled in the core for PHP 5.4, so you should not load it by hand.

Please check that you don’t have:

  1. json.ini somewhere in the /etc/php5/{mods-available} left over from previous PHP 5.5 installation

  2. you are not loading JSON extension from the mentioned script, e.g. no dl(json.so).

  3. Make sure you have stopped and started Apache2 (same applies to php5-fpm) when changing major versions. The symptoms might indicate that there was some stuck Apache2 thread with previous PHP from package loaded (that would be PHP 5.5 with json-c based JSON extension in this case).

OTHER TIPS

Since you're saying that the json extension is loaded in phpinfo()'s output you could be dealing with a bug. Have you checked if the module file is actually there in the filesystem?

You have the following options:

  1. Compile PHP 5.4 from source with Apache 2.4
  2. Upgrade to the same repo's stable version which will give you PHP 5.5 + Apache 2.4.
  3. Submit a bug with the Ondrej in Ubuntu's PPAs and wait for it to be resolved.

For more information check the debphp site.

Submitting a bug is a must, since if it is a real one it must be fixed for all users. You could firstly go with option 2 if you don't conflict with the Migration guidelines like backward compatibility, deprecated functions, etc.. SO check it and decide.

It also strongly varies depending on the machine you have to do this with. If it is a critical production server, you may not want to compile of change versions on it. Go file the bug and see what the package maintainers have to say about this.

Also please write a reply here when your problem is resolved. I am quite curious as to what it is and hopefully was. :D

One point that doesn't diagnose or solve the issue (and seems to refer to PHP 5.5), but might help with tracing its root cause:

  • This Debian bug report and Phil Sturgeon's blog explain that some Linux distributions have chosen to replace the official PHP implementation of ext/json with the drop-in compatible pecl-json-c. The rationale was that Douglas Crockford's implementation contains a non-free clause in the license ("The Software shall be used for Good, not Evil"). See also this blog post.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top