Extensions to PHP installation MongoDB in Linux

Source: Internet
Author: User
Tags mongodb php mongodb phpinfo script php

Environment Description:

centos5.6 32bit
PHP 5.2.17
PHP Installation Path/usr/local/php
Phpize Path/usr/bin
Php-config Path/usr/bin
PHP.ini Path/etc/

1. First download the PHP mongodb extension
Download MongoDB's extended source package from the Http://pecl.php.net/package/mongo site

wget http://pecl.php.net/get/mongo-1.4.5.tgz

2. Unpack the installation package

Tar zxf mongo-1.4.5.tgz

3. Into the decompression directory, run Phpize for installation preparation

CD mongo-1.4.5
/usr/local/php/bin/phpize

4. Installation and compilation

After the above command runs, the Configure file is generated in the directory
Use the./configure command to install the configuration, and then compile the installation using make && made install, which commands the following:

./configure--with-php-config=/usr/local/php/bin/php-config
Make && Make install

5. Edit PHP.ini adds the following line add MongoDB extension


Extension=mongo.so

Restart the Web container, and then view the phpinfo and see the contents of the MongoDB to indicate that the installation was successful.

Example

Server environment cent OS 5.6 32 bits, PHP version 5.2.17 compile installation, installation path/usr/local/php

First download the latest PHP mongodb extension source code can be downloaded in Http://pecl.php.net/package/mongo to

wget http://pecl.php.net/get/mongo-1.2.0.tgz

Tar zxf http://pecl.php.net/get/mongo-1.2.0.tgz

CD mongo-1.2.0

After entering the folder, first run phpize to prepare to compile the extended environment, phpize the introduction of this program here

/usr/local/php/bin/phpize

After the run, the results are as follows:

After running, the./configure script is generated, and this time we run the./configure script to configure
./configure--with-php-config=/usr/local/php/bin/php-config

--with-php-config This parameter is to tell the configuration script php-config the path of this program, Php-config's introduction here

The above command runs in a properly configured environment with the following results

Then use make to compile the extension

Make && make install

The results of the correct compilation are as follows (the following figure is the last few lines of the compiled output)

After completing, please edit your php.ini file to add one line

Extension=mongo.so
The general default for compiling PHP's INI file is
/usr/local/php/etc/php.ini

Restart your Web server or PHP-FPM, print phpinfo, and if you see the following, congratulations, MongoDB's extended installation was successful.

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.