MongoDB installation in Ubuntu 14.04

We’ll be seeing how to install MongoDB and get it working with PHP.

If you had followed the step of installing mongo PECL extension you can undo it by doing the following, as this will be provided by the php5-mongo package, including the required changes in the php configuration, which we’ll be installing shortly afterwards.

  • Removing any entry in the php.ini file that you made for mongo extension.
  • Remove the PECL extension by:
sudo pecl uninstall mongo

Now do the following steps to complete the installation:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
sudo apt-get update

sudo apt-get install -y mongodb-org
sudo apt-get install php5-mongo

After this restart your computer, only after that the MongoClient class will be available for use.

References

How to test the PHP installation.

I had forgot one important component in the PHP programming, the Editor. The editor is very important to help you in efficient programming, it can help you with code-assist, code-complete(tag completion), code alignment, etc..

So now get hold of a good PHP editor(I use Easy-eclipse for PHP), and type in the following code-

<html>
<head>
<title>PHP Test</title>
</head>
<body>

This is an HTML line
<?php
echo “This is a PHP line”;
phpinfo();
?>
</body>
</html>

This is arguably the most popular PHP code. The above code’s output is the complete information about the PHP version you have installed and its modules..
Try it.