Skip to content

Instantly share code, notes, and snippets.

@sophiaphillipa
Last active March 15, 2019 18:57
Show Gist options
  • Save sophiaphillipa/c8a9cfd61ee878d927f457cb6657f54a to your computer and use it in GitHub Desktop.
Save sophiaphillipa/c8a9cfd61ee878d927f457cb6657f54a to your computer and use it in GitHub Desktop.
Compile PHP MongoDb Driver for php 7 (even if you have more than one php on env)

Compile PHP MogoDbDriver for php 7

This gist took PHP - Manually Installing the MongoDB PHP Driver, as reference.

First locate your php-config file. To do so, you can trace it with locate php-config. It will be something like this:

/usr/php/7.0.9/exec/bin/php-config

It's the file that has all compiled php settings, and it will be used to tell config command, wich PHP should be compiled for.

Choose any path to do:

git clone https://github.com/mongodb/mongo-php-driver.git
cd mongo-php-driver
git checkout v1.3 (or any other if you want to) git submodule sync && git submodule update --init
phpize
./configure --with-php-config=Your-php-config
make
make install

Obs. At .configure line, Your-php-config should point to your php compiled directory, where should be a real php-config file. Like this example: /usr/php/7.0.9/exec/bin/php-config After that, just copy mongodb.so to php extensions path, and point it inside php.ini php extensions path, and php.ini location can be found using phpinfo function, or php -i on cli.

If there is any problem related to OpenSSL location, at .configure run time, just try to link it, like this:

cd /usr/local/include $ ln -s ../opt/openssl/include/openssl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment