Ubuntu 16.04 Installation Mongodb_mongodb

Source: Internet
Author: User
. Import the public key of a software source
sudo apt-key adv--keyserver hkp://keyserver.ubuntu.com:80--recv EA312927
1

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
1

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
1

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
1

3. Update the software source and install MongoDB

sudo apt-get update
sudo apt-get install-y mongodb-org
1 2

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
1

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

[Unit]
Description=high-performance, Schema-free document-oriented database
after=network.target
Documentation= Https://docs.mongodb.org/manual

[Service]
user=mongodb
group=mongodb
Execstart=/usr/bin/mongod --quiet--config/etc/mongod.conf

[Install]
Wantedby=multi-user.target
1 2 3 4 5 6 7 8 9 10 11-12

5. Startup, restart, and shutdown commands

sudo service mongod start
sudo service mongod restart
sudo service mongod stop
1 2 3

Full Uninstall of 6.mongodb
Stop running MongoDB first

sudo service Mongod stop
1

Uninstall software again

sudo apt-get purge mongodb-org*
1

deleting databases and log files

sudo rm-r/var/log/mongodb
sudo rm-r/var/lib/mongodb
1 2

7. Add php MongoDB Extension

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

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

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.