Ubuntu 14.04 installation MongoDB and PHP MongoDB driver detailed introduction _mongodb

Source: Internet
Author: User
Tags fpm install php install mongodb mongodb mongodb driver php mongodb mongodb support

Description

MongoDB is a very famous NOSQL database, the following is the installation of MongoDB under Ubuntu 14.04, as well as the configuration for PHP (driver installation, etc.), this method is applicable to Homestead.

Install MongoDB

1. Add Source

sudo apt-key adv--keyserver hkp://keyserver.ubuntu.com:80--recv 7f0ceb10
Echo ' Deb http:// Downloads-distro.mongodb.org/repo/ubuntu-upstart Dist 10gen ' | sudo tee/etc/apt/sources.list.d/mongodb.list
sudo apt-get update

2. Start Installation

You can customize the installation of Package please see here.

sudo apt-get install-qq mongodb-org

Install complete Check to open:

$ PS-EF | grep MONGO
MongoDB 15683 1 1 03:00? 00:00:37/usr/bin/mongod--config/etc/mongod.conf

Check version:

$ MONGO--version
MongoDB Shell version:2.6.6
$ MONGO
> Db.test.save ({test:100})
> Db.test.fin D ()
{"_id": ObjectId ("549253f4d91767276c02fc14"), "Test": 100}

Path information and default parameter descriptions:

Sources:/usr/bin/
Logs:/var/log/mongodb/mongod.log
Data:/var/lib/mongodb/
Default ip:127.0.0.1
Default Port MongoDB is listening:27017

All the above information can be modified by editing/etc/mongod.conf.

Open/Close

$ sudo service mongod start
$ sudo service mongod stop
$ sudo service mongod restart

Install PHP Mongodb Driver

1. Install Driver

echo "No" > Answers.txt
sudo pecl install MONGO < answers.txt
RM answers.txt

2. Open PHP Extension

echo ' extension=mongo.so ' | sudo tee/etc/php5/mods-available/mongo.ini
sudo ln-s/etc/php5/mods-available/mongo.ini/etc/php5/fpm/conf.d/ Mongo.ini
sudo ln-s/etc/php5/mods-available/mongo.ini/etc/php5/cli/conf.d/mongo.ini

Reboot the server

sudo service php5-fpm restart

Verify that the installation is successful

$ php-i | grep ' Mongo '
MongoDB Support => enabled: Sparkles:: Sparkles:: Sparkles

Thank you for reading, I hope to help you, thank you for your support for this site!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.