Install mongodb server and php client extensions under centos5.4

Source: Internet
Author: User
Tags install mongodb mongodb server mongo shell mongodb gui
MonjaDB is a MongoDB GUI client tool that provides intuitive MongoDB data management functions and supports WindowsMacLinux.

1. Install the server

1. Download MongoDB

Http://www.mongodb.org/downloads

I downloaded version 1.6.

2. decompress and move all the files in the bin directory of the decompressed package to the/usr/local/bin directory.

3. Run the mongo server program

/Usr/local/bin/mongod -- port <端口> -- Bind_ip <本机ip> -- Dbpath <数据库文件存放的位置>

If you want to start up

Add the following line to/usr/local/etc/rc. local.

Usr/local/bin/mongod -- port <端口> -- Bind_ip <本机ip> -- Dbpath <数据库文件存放的位置> >/Dev/null &

4. test whether the installation is successful.

Run commands

#/Usr/local/bin/mongo -- port 4312 -- host 127.0.0.1

Display

MongoDB shell version: 1.6.0

Connecting to: 127.0.0.1: 4312/test

> Helpdb. help () help on db methodsdb. mycoll. help () help on collection methodsrs. help () help on replica set methodshelp connect ing to a db helphelp admin administrative failed misc things to knowshow dbs show database namesshow collections show collections in current databaseshow users show users in current databaseshow profile show most recent system. profile entries with time> = 1 msuse Set current databasedb. foo. find () list objects in collection foodb. foo. find ({a: 1}) list objects in foo where a = 1it result of the last line evaluated; use to further iterateexit quit the mongo shell to Play slowly.

Ii. Install the client

1. Go to http://pecl.php.net/package/#to download the relevant expansion package.

In addition, there are many related resources on github.

Http://github.com/mongodb/mongo-php-driver/downloads

2. Run the followingCommand

Pecl install http://pecl.php.net/get/mongo- . Tgz

3. Enter/etc/php. d.

Create mongo. ini

Add the following content

Extension = mongo. so

4. Restart apache

5. Write a php script to test whether the script is successful.

#/Usr/local/bin/mongo -- port 4312 -- host 127.0.0.1

> Show dbs;

/* Select a database */

> Use test;

/* View Collection */

> Db. getCollectionNames () // display the result ["system. indexes", "system. users"]

// Create a new Collection> db. createCollection ('cartoons');> exit; Convert shard = new Mongo (); $ m = new Mongo ("127.0.0.1: 4312 "); then you can view the results on the webpage or execute the command line.

Iii. Others

For more information, see

Http://www.mongodb.org/display/DOCS/Tutorial

Http://www.php.net/manual/en/mongo.installation.php

Postscript:

I have heard about this data table. I will take a look at it today. I will share it with you in the process of data operations (adding, deleting, modifying, and querying) and database backup, I believe it is easy to get started.

In addition, from the official perspective, there are still many third-party calls. Javascript (framework) is also supported, which is rarely used. It's worth a bit of fun.

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.