Install MongoDB PHP Driver to XAMPP in UBUNTU.

@mit $ingh. April 25, 2017 Comments

To install the php driver for MongoDB do the following:

Note prior to this operation you need to have installed the actual MongoDb server. For details of the installation procedure see here.

1. You will need to make sure that you have the XAMPP development files installed along with the basic XAMPP version. These are not installed by default and have to be added to the basic installation. These development files include the header files that are necessary to use pecl program which installs extensions.

use command such as

sudo tar xvfz xampp-linux-devel-1.8.0.tar.gz -C /opt

to extract the additional files to the existing XAMPP installation.

 

Note that if you install XAMPP using the new .run installer file (versions newer than 1.8.2) then you will get the option during setup to install the development files as well as the core files. Remember to select both.

2. Run the pecl installer

sudo /opt/lampp/bin/pecl install mongo

If the autoconf program is not installed on your system then this will still result in an error stating…

Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, re-run this script.

3. Install autoconf

sudo apt-get install autoconf

after the installation use the following command

export PHP_AUTOCONF=/usr/bin/autoconf

4. Re-run the pecl installation as above – should work without errors.

sudo /opt/lampp/bin/pecl install mongo

Note also that I had some difficulty installing this on peppermintOS as it did not have a ‘C’ compiler so I had to run the following additional commands first to get the pecl install command to work.

sudo apt-get install gcc
sudo apt-get install make
sudo /opt/lampp/bin/pecl install mongo
 
#then step 5

5. Finally add the following to the php.ini file (located in /opt/lampp/etc folder)

extension=mongo.so

6. restart xampp server

sudo /opt/lampp/lampp start

That’s it!

  • ubuntu
  • mongoDB
  • XAMPP
  • php-mongodb
  • php-extension