To install PHP Legacy Mongo 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 legacy PHP Mongo extension using the following command

pear install -f pecl/mongo

 

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

extension=mongo.so

 

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 mongo