Adding Mongo DB driver to XAMPP
Posted: January 26, 2012 Filed under: Linux, Techno irrelevency ., Ubuntu, Web 2.0 | Tags: database, drivers, internet, linux, mongo, mongodb, open, opensource, php, php extensions, source, tutorial, ubuntu, web, xampp 8 CommentsLike many developers I use XAMPP for PHP development. But adding PHP extensions in xampp to does not seem to have a direct procedure . So when I wanted mongodb drivers I was on my own to figure out how to get it working . Here is the knowledge I gained .
I am using Ubuntu oneiric ocelot machine so this procedure is similar for all *NIX machines (Sorry windows users but the procedure must similar).
- First download and install Mongo db from mongodb.org/downloads
- Secondly download the PHP MongoDB driver source from github.com/mongodb/mongo-php-driver
- Now to compile the code
- You need phpize to compile the source code, so install php5-devpackage by running `sudo apt-get install php5-dev`
- Navigate into the mongo-php-driver directory and run `phpize` on the terminal
- Then run `./configure` to check for dependencies
- Run `make` to build the package
- You need phpize to compile the source code, so install php5-devpackage by running `sudo apt-get install php5-dev`
- Assuming XAMPP is installed at `/opt/lampp/` copy `mongo.so` and `mongo.la` from `modules` directory inside mongo-php-driver directory to `/opt/lampp/lib/php/extensions/no-debug-non-zts-20090626/` directory
- Add the line `extension=mongo.so` to `/opt/lampp/etc/php.ini`
- Start mongodb and xampp servers and run the program test program from php.net/manual/en/mongo.tutorial.php to check if it is working
[…] The above steps only for those installed php,apache separtely, not for xampp. If you are using Xampp follow this link https://abstract2paradox.wordpress.com/2012/01/26/adding-mongo-db-driver-to-xampp/ […]
Greetings
I followed your steps and I am getting 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
I am using the 64 bit of ubuntu
The problem is quite easy to figure out from the error itself.
Xampp is compiled for 32bit systems , but when you compile mongo.so on a 64bit system you get a 64bit version of the driver , So you cannot use them together .
So try compiling it on a 32bit system and using that .
I have a Issue in Step5: Add the line `extension=mongo.so` to `/opt/lampp/etc/php.ini`
When I add the line, and restart lampp, php doesn’t work. When I go in navigator to my info.php, try to download-it. Only work when I comment that line.
I have lampp in 32 bits, I have compiled mongo-php-driver with 32 bits flag, and followed all the steps. I tried put: extension_dir=/path/to/no-debug-non-zts-20090626. And use extension complete path: extension=/path/to/no-debug-non-zts-20090626/mongo.so
Any idea?
Hello im having the same problem, did you get to fix this ?
I’m too gotcha on this problem with 64 bit XAMP on Ubuntu 12.04.
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: undefined symbol: zend_new_interned_string in Unknown on line 0
[…] https://abstract2paradox.wordpress.com/2012/01/26/adding-mongo-db-driver-to-xampp/ […]