Installing MongoDB PECL extension

The MongoDB PECL extension has not been installed or enabled

If you have installed MongoDB and you get the above error or something similar to it, you will need to install the php extension. It’s quite easy, shouldn’t take more than a couple of minutes. All the commands were executed as root, if you want to use the sudo mechanism, just prefix all the commands with sudo.

Install the required packages

apt-get install php-pear php5-dev make

If everything went ok, simply install the extension by executing this command:

pecl install mongo

Activate the MongoDB extension

I have Ubuntu 12.04 server edition installed on the server so I simply added a new ini file containing one line:

echo "extension=mongo.so" > /etc/php5/apache2/conf.d/mongo.ini

Now restart web server (in my case Apache 2.2) and enjoy:

service apache2 restart

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