Imran Omar Bukhsh
Imran Omar Bukhsh

Reputation: 8071

Installing Mongodb with Lamp On Ubuntu ( Linux )

I followed the following steps to install mongo's php drivers with lampp.

http://abstract2paradox.wordpress.com/2012/01/26/adding-mongo-db-driver-to-xampp/

When I start lampp its gives the following error

Warning: PHP Startup: Unable to load dynamic library '/opt/lampp/lib/php/extensions/no-debug-non-zts-20090626/mongo.so' - /opt/lampp/lib/php/extensions/no-debug-non-zts-20090626/mongo.so: wrong ELF class: ELFCLASS64 in Unknown on line 0

Any ideas?

Thanking you

Upvotes: 3

Views: 4579

Answers (2)

Imran Omar Bukhsh
Imran Omar Bukhsh

Reputation: 8071

The problem was as is outlined by Derick above. Although the way the problem got solved was download a 32 bit version of the ubuntu os and running it as a virtual machine on my pc using vmware. Later followed the 'Manual Installation section' on this page for the php driver installation and it all worked. Got the php drivers from github as mentioned in the page.

Later i copied the file mongo.so from the php file extensions directory running on my virtual machine to my parent os and it all works now!

Upvotes: 0

Derick
Derick

Reputation: 36764

This means that your PHP is compiled in 32-bit mode, but the mongo extension as 64-bit mode. I believe Apple's compiled PHP is in 32-bit mode as well, you can verify that with:

php -r 'echo PHP_INT_MAX, "\n";'

If that shows

9223372036854775807
you're on a 64-bit platform.

Now, in your case you will need to make sure that you compile the MongoDB extension with a 32-bit architecture. From http://artur.ejsmont.org/blog/content/how-to-build-mongodb-pecl-extension-in-32bit-for-php-52-on-macosx-snow-leaopard I believe you can do that with:

pecl download mongo
tar -xvzf mongo-1.2.7.tgz
cd mongo-1.2.7

CFLAGS="-m32"

phpize
./configure
make
make install

Upvotes: 6

Related Questions