To install PHP MongoDB Extension for PHP to communicate with the MongoDB Server


1. Make sure you have PHP PECL, if you do not have it installed, install it using

yum install php-pecl php-dev -y

2. Now, install PHP MongoDB extension using the following command

pecl install mongodb


3. Once the installation is complete add the following line to your PHP.ini file


4. Now, for the changes to take effect restart the apache web server using the below command

service httpd restart


5. You can verify whether the extension is loaded or not by running the below command

php -m | grep -i mongodb