sudo apt install php-dev sudo pecl install mongodb
Create an .ini module (check what PHP version is installed: 7.0, 7.3,etc.
sudo nano /etc/php/7.3/mods-available/mongodb.ini
Add the following line:
extension=mongodb.so
Save and enable module, restart the apache server:
sudo phpenmod mongodb sudo service apache2 resstart
Version could be different, just check phpinfo():