使用MongoDB Extension运行PHP失败(PHP 5.3.8,操作系统:Centos 5.4)

I have a problem on running PHP's MongoDB extensions

Read the solution at the end of this post

I successfully installed it using 3 different methods but it doesn't show the extension in phpinfo()

1-Using pecl install mongo ( it succeeded and asked me to add extension=mongo.so) in php.ini 2-By downloading the source the compiling it. 3-From yum installing php-pecl-mongo

All methods succeed without errors but when I run phpinfo I don't see the Mongo extension loaded and when I try to call it asks for installing the extension.

How do I debug this issue (i.e. Where can I find such logs)

And how do I Find info about Mongo's compatibility with PHP 5.3.8 ?

This is what I get at the end of the installation :

Notice: I'm sure that I copied the mongo.so file to the extension path of php as I'm using other extension from the same dir and they're working

Libraries have been installed in:
   /sources/mongo/mongodb-mongo-php-driver-d7c19b8/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Installing shared extensions:     /usr/local/lib/php/extensions/no-debug-non-zts                                                -20060613/
-bash-3.2# cp /usr/local/lib/php/extensions/no-debug-non-zts-20060613/mongo.so /  

Fixed --> the issue was that my php api wasn't the same version as PHP i.e. php-devel/php5-devel needed to be updated.

When you compile a module manually you have to copy it to a path which PHP knows where to look for custom modules.

From the cli, try this command:

php -i | fgrep -i configure

You should see an option like:

--with-config-file-scan-dir=/bridge/to/nowhere

Make sure, after you compile the module, that you copy the module from the mongo source directory, to the /bridge/to/nowhere directory, so PHP can pick it up.

With any luck, it should be listed when you do a php -m.

What happens if you change the 'extension=mongo.so' line in your php.ini file to:

extension=/usr/local/lib/php/extensions/no-debug-non-zts-20060613/mongo.so

When php starts up, does it produce any error message? If not, please verify that php -i |grep -e 'Loaded Configuration File' shows the expected php.ini file.

The mongodb php extension should work just fine with php v5.3.8 (and php-fpm).