Ubuntu Install MongoDB

Source: Internet
Author: User
Tags install mongodb

Reference: http://blog.csdn.net/zhushh/article/details/52451441

1. Import the public key of the software source

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927

2. Create a software source list file for MongoDB
ubuntu12.04

echo "deb http://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list

ubuntu14.04

echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list

ubuntu16.04

echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list

3. Update the software source and install MongoDB

sudo apt-get updatesudo apt-get install -y mongodb-org

If you want to install a specific version, use the following command:

sudo apt-get Install-y mongodb-org=3.2.9 mongodb-org -server=3.2 .9 mongodb-org-shell=3.2.9 MongoDB -org-mongos= 3.2.9 mongodb-org-tools=3.2.9  

4. Configure the boot file  
If it is a ubuntu16.04 version, you need to create a new/lib/systemd/system/mongod.service file manually and write the following:

[Unit]Description=High-performance, schema-free document-oriented databaseAfter=network.targetDocumentation=https://docs.mongodb.org/manual[Service]User=mongodbGroup=mongodbExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf[Install]WantedBy=multi-user.target

5. Start, restart, and close commands

sudo service mongod startsudo service mongod restartsudo service mongod stop

Full Uninstall of 6.mongodb
Stop running MongoDB first

sudo service mongod stop

Uninstall the software again

sudo apt-get purge mongodb-org*

Delete database and log files

-r /var/log/mongodbsudo rm -r /var/lib/mongodb

7. Add the MongoDB extension of PHP

# pecl install mongodb# echo "extension=mongodb.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`

Reference Links:
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/
http://mongodb.github.io/mongo-php-driver/

Ubuntu Install MongoDB

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.