PHP Install MongoDB Extension

Source: Internet
Author: User
Tags install mongodb install openssl mongodb version openssl

This article will tell me about the process of installing MONGODB extension, you can refer to

Installation Environment

Linux Environment: CentOS 6.5

Apache Version: 2.4

PHP Version: 5.4.3

MongoDB version: 2.6.5

One, download mongo-php extension installation package

Can be downloaded from GitHub, address is https://github.com/mongodb/mongo-php-driver-legacy

Download the files to a random directory and unzip them.

You need to install a series of compilation tools before installation, you can skip this step if you have already installed.

Installing the Build Tool

Yum Install GCC gcc-c++ autoconf automake

Make: * * [Io_stream.lo] Error 1 errors may appear in the Do all step.

So we need to install Openssl-devel.

Yum Install Openssl-devel

At this point, all the pre-work is ready.

Second, compile and install mongo-php extension

The file name of the mongo-php extension file I downloaded is mongo-php-driver-legacy-master.zip and placed in the/home/demon directory.

Unzip Mongo-php-driver-legacy-master.zip to mongo-php. Then go to the mongo-php directory

Unzip -Q Mongo-php-driver-legacy-master. Zip mv mongo-php-driver-legacy-master mongo-phpcd MONGO-phpphpize. /Configure  make all makeinstall

If there is no problem during the installation, the PHP driver directory will appear after make install, for example:

Installing shared extensions:     /usr/lib64/php/modules/

To load this extension when PHP is started, add the following code to the/etc/php.ini:

[Mongodb]extension=mongo.so

Third, restart Apache service

Service httpd Restart

Output phpinfo (); If you see MONGO, the installation is successful.

Iv. Testing the PHP code to connect MongoDB

<? PHP Try {    $connnew Mongo (' 127.0.0.1 ');} Catch (Exception$e) {    echo$e, GetMessage ();}

If failed to connect To:127.0.0.1:27017:permission denied appears, then run the following statement to resolve

1 Service httpd Restart

PHP Install MongoDB Extension

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.