MongoDB PHP Module (Extension) on CentOS 5/6/7

MongoDB PHP driver is very simple install on Linux. You need just PEAR with PECL repository. Normally PHP development package and PHP Pear package installation from package management system is enough to get PEAR working. These instructions are intended specifically for installing the MongoDB PHP Driver (Extension) CentOS.
MongoDB_Logo

Step #1 Required Packages

Let’s install a compiler, the PHP Extension and Application Repository (PEAR), and PHP development tools:

# yum -y install gcc php-pear php-devel

Step #2 MongoDB PHP driver

Now let’s install the MongoDB PHP driver (extension) with PECL:

# pecl install mongo

Next ‘MongoDB Enterprise Authentication’ will be prompte, If you’re not specifically using SASL, then hit enter to continue (thus answering ‘no’):

Build with Cyrus SASL (MongoDB Enterprise Authentication) support? [no] :

Step #3Configure PHP

Now add MongoDB extension on php configuration file.

# vim /etc/php.ini
extension=mongo.so

Step #4 Restart Apache

And now restart Apache service using following command:

# service httpd restart

Step #5 Verify the Extension

Now verify that the extension using the following command:

# php -m | grep -i mongo

Or

Create phpinfo.php file in your system document root.

# vim /var/www/html/phpinfo.php

Add below lines:

<?php
phpinfo ();
?>

Now run the below URL:

http://IP_Address/phpinfo.php

Mongo

Enjoy it!

No Responses

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.