Installing Mongodb with Lamp On Ubuntu ( Linux )

♀尐吖头ヾ 提交于 2019-12-10 19:53:46

问题


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


回答1:


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



回答2:


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!



来源:https://stackoverflow.com/questions/9392054/installing-mongodb-with-lamp-on-ubuntu-linux

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!