1
votes

I'm trying to install the MongoDB PHP driver Using PHP 7.2 on AWS EC2 Ubuntu. I used sudo pecl install mongodb. it seems to have installed without any errors.

However, when loading phpinfo() I don't see any reference to Mongo. When I try to run:

$manager = new MongoDB\Driver\Manager("mongodb://localhost:27017");

Fatal error: Uncaught Error: Class 'MongoDB\Driver\Manager' not found in /var/www/html/website/test.php:3 Stack trace: #0 {main} thrown in /var/www/html/website/test.php on line 3

I did put in extension=mongodb.so into my php.ini

I'd appreciate assistance as to why this isn't working.

1
Create a file info.php and put it in root directory. Call phpinfo() and check for mongo db. You also need to restart the server after changing php.iniSameer Reza Khan
I did not see mongo in phpinfo() even after restart apache2.Thanksmeepo sf
You need to check the installation documentation. Make sure your driver is of same architecture as your php installation i.e x86 or x62. You can see that in phpinfo().Sameer Reza Khan

1 Answers

0
votes

I tried to install driver using

sudo apt-get install php-mongodb

and it works.