PHP extension Installation and connection MONGO test

Source: Internet
Author: User
Tags fpm mongodb version

System: centos6.5

MongoDB version: CurrentStable release (3.0.6)

First download MongoDB on the official website

Https://www.mongodb.org/downloads

Select the RHEL6 version under Linux, as determined by the system.

I am downloading a binary package with the file name mongodb-linux-x86_64-rhel62-3.0.5

Put the above file under the/mydata.

Unzip to MONGO folder

[Email protected] mydata]# tar zxvf mongodb-linux-x86_64-rhel62-3.0.5.gz

[Email protected] mydata]# MV mongodb-linux-x86_64-rhel62-3.0.5 MongoDB

Start MONGO

[Email protected] mongodb]#/mydata/mongodb/bin/mongod--dbpath/mydata/mongodata

The following prompt appears to indicate success

2015-09-26t11:01:31.021-0700 I NETWORK  [Initandlisten] waiting for connections on port 27017

To launch successfully here, we started to install PHP MONGO extension and test MongoDB

Here in my virtual machine pre-installed with Yum LNMP environment, here to install a MONGO extension is good

PECL Install MONGO

The location of the mongo.so is displayed after the installation is complete.

Installing '/usr/local/lib/php/extensions/no-debug-non-zts-20121212/mongo.so '

At this time to see the PHP extension directory is not the same as the above directory, if different need to copy mongo.so to the appropriate directory

Php-i | grep extension

Vim/etc/php.ini

Add extension=mongo.so to last line

Note that it is important to ensure that the php.ini path is the path specified by the PHP configuration file: Execute PHP--ini to view the PHP configuration file path, php.ini copy to the specified path if the current path is not php.ini

Restart PHP-FPM

Service PHP-FPM Restart

Set up a test file called mongotest.php.

<?php  $mongo = new MONGO ();  $dbs = $mongo->listdbs ();  Print_r ($dbs);?>

Visit http://localhost/mongotest.php

Get the following results

To test success here

PHP extension Installation and connection MONGO test

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.