Troubleshooting and php operations for installing mongodb in ubuntu

Source: Internet
Author: User
Tags install php install mongodb mongodb


I. Install mongodb


// Import the MongoDB public GPG Key

Sudo apt-key adv -- keyserver hkp: // keyserver.ubuntu.com: 80 -- recv 7F0CEB10

// Create the configuration file/etc/apt/sources. list. d/mongodb. list

Echo 'destroy http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen '| sudo tee/etc/apt/sources. list. d/mongodb. list

// Reload the local Package Database

Sudo apt-get update

// MongoDB stable Enterprise Edition

Sudo apt-get install-y mongodb-org

// Start

Sudo service producer d start

// Enter the client

Mongo

An error is reported.

Failed to connect to 127.0.0.1: 27017, reason: errno: 111 Connection refused

Enter the command

D error

Mongdb-error

ERROR: Insufficient free space for journal files

Please make at least 3379 MB available in/data/db/journal or use-smallfiles

Use

Mongod-smallfiles can be successfully created.

II. Install php extension


Download address

Https://github.com/mongodb/mongo-php-driver

Download the installation package

Tar zxvf mongodb-mongodb-php-driver.tar.gz

Cd mongodb-php-driver

Phpize
./Configure

Sudo make install

Php. ini

Extension =/usr/lib/php5/20121212/mongo. so

III. Test


// Connect to mongodb
$ M = new clients client ();
Echo "Connection to database successfully ";

$ Db = $ m-> mydb;
Echo "Database mydb selected ";
$ Collection = $ db-> createCollection ("mycol ");
Echo "Collection created succsessfully ";

// Client

> Show dbs;
Admin (empty)
Local 0.031 GB
Mydb 0.031 GB
>

With mydb database added

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.