Question

I need the MongoDB PHP driver on my CentOS 5.4 machine. My PHP version is 5.1.6. I downloaded the RPM and installed it. That created several files in /usr/bin directory. I copied

/usr/bin/mongo

to

/usr/lib/php/modules

which was what extension_dir showed on doing phpinfo();.

I also added

extension=mongo.so

in /etc/php.ini. However on executing my PHP script, i still get

Mongo class not found.

What's going wrong here ?

Also, my phpinfo() shows PHP version 5.1.6 whereas running PHP from command line shows 5.3.3. Could anything be wrong with that ?

Thanks in advance.

Was it helpful?

Solution

You're saying your webserver and command line PHP report different versions. These are going to be installed in different locations, and their extensions are API incompatible with each other.

When you installed the php_mongo extension, it may have used the command line php to determine the directory to install the extension to.

Make sure you have the correct php_mongo for the php version of your webserver, and it is in the correct extensions directory. (get the directory from the php.ini returned by phpinfo())

I hope you realise PHP 5.1 is also many years out of date. Unless you have a specific reason to use a version that old, you should also look at upgrading to a more recent version.

Edit:

Just read your comment "I must also mention that /usr/bin/mongo is a binary executable file but its not having a .so extension. Im copying it as is to /usr/lib/php/modules"

No no no! :)

This is the mongo command line client. This is not the PHP extension!

You can run a find /* -name "mongo.so" to see where the installer put the file, this will probably also give you an indication of which version of PHP it was installed for.

OTHER TIPS

It looks as though you are confusing the RPM-packages for the MongoDB server with the requirements to install the MongoDB PHP driver. The PHP driver provides access to the server from your PHP applications, and does not install any command line tools.

restart httpd !

yum service httpd restart
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top