The Easy Way to Install the MongoDB PHP Driver on Ubuntu 12.04

February 24, 2013

See other posts in the Code category.

First, to get this thing going, we'll need to resolve some dependencies. To do that, run this command from the terminal:

$ sudo apt-get install php-pear php5-dev

Next, you should easily be able to install the driver with the following command:

$ sudo pecl install mongo

What makes Ubuntu 12.04 a little different from other systems in how PHP extensions get loading when Apache/PHP starts. To make sure this extension gets loaded, we'll need to add a .ini file to "/etc/php5/conf.d". To do that, run the following command:

$ sudo touch /etc/php5/conf.d/mongo.ini

After creating the file, add this line of content:

After you've saved your new .ini file, restart Apache and verify that the extension is loading with phpinfo().

Zac Vineyard

Zac Vineyard

I'm Zac, an open-source web engineer in Idaho.

Code, Higher-ed, SEO, and Business