Centos – How to install pecl spidermonkey on CentOS 6

centospeclPHP

Running the following command:

> sudo pecl install spidermonkey

I receive the following error:

...
... a bunch of successful checks ...
...
checking whether to enable spidermonkey support... yes, shared
configure: error: jsapi.h not found. Please reinstall libjs.
ERROR: `/var/tmp/spidermonkey/configure' failed

I attempted to remedy the problem by installing js-devel, which, after wrestling with various yum repositories, I finally did manually like so:

> wget http://pkgs.repoforge.org/js/js-1.60-1.el6.rf.x86_64.rpm
> wget http://pkgs.repoforge.org/js/js-devel-1.60-1.el6.rf.x86_64.rpm
> yum install js-1.60-1.el6.rf.x86_64.rpm
> yum install js-devel-1.60-1.el6.rf.x86_64.rpm

(Not sure why js-devel required js to be installed first … but, it complained when I tried to install js-devel solo.)

Re-running the pecl install, I receive the same error. Is my understanding that the js-devel package contains the libjs stuff simply incorrect? Are there additional steps? Or, do I need to look elsewhere to get libjs?

ADDENDUM: I also tried removing the above packages (using yum) and installing these builds:

> wget http://puias.math.ias.edu/data/puias/6/x86_64/os/Addons/js-1.70-12.puias6.x86_64.rpm
> yum install js-1.70-12.puias6.x86_64.rpm
> wget http://puias.math.ias.edu/data/puias/6/x86_64/os/Addons/js-devel-1.70-12.puias6.x86_64.rpm
> yum install js-devel-1.70-12.puias6.x86_64.rpm

No dice. The command line js interpreter works perfectly. But, PECL yields the same error.

Best Answer

While this doesn't address the problem of the package not installing correctly using the package manager, the steps in this article left me with spidermonkey functioning correctly in PHP:

http://devzone.zend.com/1480/using-javascript-in-php-with-pecl-and-spidermonkey/

This is a workaround, in my opinion. I'm assuming the PECL package installed through the pecl package manager is intended to work correctly. So, I'm still interested in other more qualified answers.