MongoDB Installation

From DreamFactory
Jump to: navigation, search
(mongodb driver)
(Manual Install on Linux)
Line 52: Line 52:
  
 
===Manual Install on Linux===
 
===Manual Install on Linux===
Beginning with DreamFactory 2.1.2 the newer mongodb driver is both supported and required. This gives MongoDB compatibility up to the latest version (3.2)
+
* The version of php-mongodb in the APT repositories is no longer high enough to satisfy the requirements of the mongodb repos used. Please install using PECL.
 
+
# Make sure you have all the required packages
====mongo driver====
+
#* <source lang="bash">$ sudo apt-get install php-dev php-pear build-essential libsslcommon2-dev libssl-dev libcurl4-openssl-dev pkg-config</source>
* '''used for DF 2.1.1 and earlier'''
+
# Install from PECL
* '''Ensure that you have the php-pear and php5-dev packages installed on your system. You will also need the pcre3 and sasl2 development libraries.'''
+
#* <source lang="bash">$ sudo pecl install mongodb</source>
**<source lang=bash>$ sudo apt-get install php-pear php5-dev libpcre3-dev libsasl2-dev</source>
+
# Create the ini file
* '''Use PECL to make the mongo.so file'''
+
#* <source lang="bash">$ sudo sh -c 'echo "extension=mongodb.so" > /etc/php/7.0/mods-available/mongodb.ini'</source>
**<source lang=bash>$ sudo pecl install mongo</source>
+
# Enable the extension
::'''Note''':If the the install generates any errors it will fail. You will need to troubleshoot based on the error reported.
+
#* <source lang="bash">$ sudo phpenmod mongodb</source>
* '''Add the module to your php.ini file. In debian based distributions, you can follow this procedure:'''
+
# Restart your webserver app and/or php-fpm
** '''Create a module file for your mongo installation.'''
+
**<source lang=bash>$ sudo touch /etc/php5/mods-available/mongo.ini</source>
+
** '''Edit the file you just created in your preferred text editor.'''
+
::There is a single line in the file it looks like this:
+
***<source lang=bash>extension=mongo.so</source>
+
** '''Enable the php extension'''
+
***<source lang=bash>$ sudo php5enmod mongo</source>
+
** '''Restart your web service service'''
+
***<source lang=bash>$ sudo service apache2 restart</source>  or
+
***<source lang=bash>$ sudo service php5-fpm restart && sudo service nginx restart</source>
+
 
+
====mongodb driver====
+
'''Overview'''
+
These instructions are specific to Debian-based Linuxes, but the principal is the same -- Get the dependencies. Build the .so file with PECL. Add it to your PHP.  They also assume PHP7, which we do recommend using.
+
 
+
* '''used for DF 2.1.2 and later'''
+
* '''Ensure that you have the php-pear and php-dev packages installed on your system. You will also need the some development libraries (listed below.)'''
+
**<source lang=bash>$ sudo apt-get install php-pear php-dev autoconf g++ make openssl libssl-dev libcurl4-openssl-dev pkg-config libsasl2-dev libpcre3-dev</source>
+
* '''Use PECL to make the mongodb.so file'''
+
**<source lang=bash>$ sudo pecl install mongodb</source>
+
::'''Note''':If the the install generates any errors it will fail. You will need to troubleshoot based on the error reported.
+
* '''Add the module to your php.ini file. In debian based distributions, you can follow this procedure:'''
+
** '''Create a module file for your mongo installation.'''
+
**<source lang=bash>$ sudo touch /etc/php/7.0/mods-available/mongodb.ini</source>
+
** '''Edit the file you just created in your preferred text editor.'''
+
::There is a single line in the file it looks like this:
+
***<source lang=bash>extension=mongodb.so</source>
+
** '''Enable the php extension'''
+
***<source lang=bash>$ sudo phpenmod mongodb</source>
+
** '''Restart your web service service'''
+
***<source lang=bash>$ sudo service apache2 restart</source>  or
+
***<source lang=bash>$ sudo service php-fpm restart && sudo service nginx restart</source>
+

Revision as of 19:10, 23 March 2017

Drivers

Bitnami Installs on Windows, Mac, and Linux

Note:The Bitnami packages come with an instance of MongoDB and the drivers already installed. No further action is necessary, unless upgrading from pre 2.1.2 to 2.1.2 or later.

Windows

If you have a Bitnami for Windows stack that has the older mongo driver, but need to upgrade to the mongodb driver, follow this procedure

  • Download the dll from pecl
    • http://pecl.php.net/package/mongodb
    • Click on the DLL link for the latest stable package unless you have a reason to use a different version
    • On the download page you will be presented with multiple options. You need to always choose thread safe and 32 bit (x86). Choose the version that matches the PHP version of your stack (5.5, 5.6, 7.0.)
    • unzip the package after download
  • Copy the php_mongodb.dll file to the extensions directory
    • the PHP extensions default location is
      C:\Bitnami\dreamfactory-{version number}\php\ext\
  • Edit the php.ini file
    • php.ini default location is
      C:\Bitnami\dreamfactory-{version number}\php\
    • add a line that says
      extension=php_mongodb.dll
    • save the php.ini file
  • Restart your Bitnami stack


Linux VM and Cloud Images

If you have a Bitnami for Linux VM or Cloud image that has the older mongo driver, but need to upgrade to the mongodb driver, follow this procedure

  • Clone the source
    • You can do this from anywhere that you have write access, but we recommend your user's home folder.
    • git clone https://github.com/mongodb/mongo-php-driver.git
  • Change into cloned repo and get submodules
    • cd mongo-php-driver
    • git submodule sync && git submodule update --init
  • Prepare the build environment for a PHP extension
    • phpize
  • Install the necessary libraries
    • sudo apt-get update && sudo apt-get install libssl-dev libsslcommon2-dev libcurl4-openssl-dev pkg-config
  • Configure the environment
    • ./configure --with-libdir=/lib/x86_64-linux-gnu
  • Compile the module
    • make all -j 5
  • Install the module
    • sudo make install
    • You should get output indicating that the module was installed to an extensions directory, for example /opt/binamit/php/lib/php/extensions/
  • Edit php.ini
    • Use your text editor of choice to edit /opt/bitnami/php/etc/php.ini . I like vim
    • sudo vim /opt/bitnami/php/etc/php.ini
    • Add a line indicating the new module. It can go anywhere in the file. I put mine right next to the mongo.so instruction.
      • extension=mongodb.so
    • Save the file and exit
  • Restart the Bitnami stack
  • Verify successful installation using php -m and grep

Example:

bitnami@ubuntu:~/mongo-php-drivers$ php -m | grep mongo
mongo
mongodb

Manual Install on Linux

  • The version of php-mongodb in the APT repositories is no longer high enough to satisfy the requirements of the mongodb repos used. Please install using PECL.
  1. Make sure you have all the required packages
    • $ sudo apt-get install php-dev php-pear build-essential libsslcommon2-dev libssl-dev libcurl4-openssl-dev pkg-config
  2. Install from PECL
    • $ sudo pecl install mongodb
  3. Create the ini file
    • $ sudo sh -c 'echo "extension=mongodb.so" > /etc/php/7.0/mods-available/mongodb.ini'
  4. Enable the extension
    • $ sudo phpenmod mongodb
  5. Restart your webserver app and/or php-fpm