Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 825
Imran Omar Bukhsh Avatar asked Dec 04 '25 02:12

Imran Omar Bukhsh


1 Answers

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
like image 87
Derick Avatar answered Dec 05 '25 16:12

Derick



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!