Detailed installation process of using mongodb for PHP in centOS

Source: Internet
Author: User
Tags install mongodb yum install mongodb
: This article mainly introduces the detailed installation process of PHP using mongodb in centOS. if you are interested in the PHP Tutorial, please refer to it. This article describes the complete installation and configuration process for using mongodb in centOS.

Replace yum source

We want to use yum for installation. this is a quick method, but the default yum environment of centOS does not have the content we need. Therefore, we need to manually replace the yum source with 163.

First, obtain the 163 Source:

# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

Then we will back up our local yum:

#mv CentOS-Base.repo CentOS-Base.repo.bak

Change the downloaded 163 source to the local source:

#mv CentOS6-Base-163.repo CentOS-Base.repo

Next, perform the yum source update operation:

#yum clean all#yum makecache#yum update -y

In this way, the configuration of the new yum source is complete.

Install mongodb

Next, we need to install the mongodb database under centOS.

#yum instll mongodb

Then install the server:

#yum install mongodb-server

Start mongodb:

#service mongod start

Then go to mongo:

#mongo

The above result indicates that mongodb is successfully installed.

Configure the php-mongo extension

Or install it through yum:

#yum install php-pecl-mongo

After the installation is successful, php_info () will display mongo:

Test mongodb

Test mongodb with php code to see if it can run normally:


  ListDBs (); // Obtain all database names echo $ alldb;

If the response is normal, the php operation on mongodb is successful.

For more information, see API: official documentation.

'). AddClass ('pre-numbering '). hide (); $ (this ). addClass ('Has-numbering '). parent (). append ($ numbering); for (I = 1; I <= lines; I ++) {$ numbering. append ($ ('
  • '). Text (I) ;}; $ numbering. fadeIn (1700) ;}) ;}; script

    The above describes the detailed installation process of PHP using mongodb in centOS, including the content of CentOS6, and hope to be helpful to anyone interested in PHP tutorials.

    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.