Php assembly mongo extension

Source: Internet
Author: User
Tags php mongodb script php zts
Php install mongo extension phpmongo extension installation: The server environment CentOS5.664-bit, php version 5.2.17 compilation and installation, the installation path usrlocalphp first download the latest phpmongodb extension source code, the source code can be in pecl. php. download netpackagemongo to wgetpecl. php. install mongo extension in ne php
Php mongo extension installation:



64-bit Cent OS 5.6 server environment, php 5.2.17 compiling and installation, installation path/usr/local/php



First download the latest php mongodb extension source code. the source code can be downloaded at http://pecl.php.net/package/#to

Wget http://pecl.php.net/get/mongo-1.2.2.tgz

Tar zxf mongo-1.2.2.tgz

Cd mongo-1.2.2

After entering the folder, first run phpize to prepare the compiling extension environment. here is the introduction of phpize.



/Usr/local/php/bin/phpize






----------------------------------------------
The following solutions are available for installation exceptions:



Based on the lamp environment installed in yum in this blog, phpize is located at/usr/bin, php-config is located at/usr/bin, and php. ini is located at/etc/

1. first, download the corresponding mongodbextended package from http://pecl.php.net/package.

2. decompress the extension package and enter the decompressed directory.

Tar-zxf mongo-1.4.1.tgz

Cd mongo-1.4.1

3. execute phpize in the mongo-1.3.2 directory, the command is as follows :( Note: This tool is php add extension tool, my phpize location is/www/php/bin/phpize)

/Usr/local/php/bin/phpize

Note: Sometimes there is a bleeding error:

Processing ING:

PHP Api Version: 20041225

Zend Module Api No: 20060613

Zend Extension Api No: 220060519

Cannot find autoconf. Please check your autoconf installation and

$ PHP_AUTOCONF environment variable. Then, rerun this script

The problem is that m4 and autoconf are not installed.

You can download the http://ftp.gnu.org/gnu/m4/m4-1.4.9.tar.gz http://ftp.gnu.org/gnu/autoconf/autoconf-2.62.tar.gz installation package installation

Or yum-y install m4 autoconf

Generate the configure file

4. execute the following command:

./Configure -- with-php-config =/usr/local/php/bin/php-config

Note: The-with-php-config parameter must specify the location of the php-config file, rather than the location of the php. ini file.

Creating libtool

Appending configuration tag "CXX" to libtool

Configure: creating./config. status

Config. status: creating config. h

5. check the configuration information and compile and install the configuration correctly:

Make & make install

The correct compilation and execution results are as follows:

Build complete.

Don't forget to run 'Make test '.

Installing shared extensions:/usr/local/php/lib/php/extensions/no-debug-non-zts-20130712/

6. after compilation and installation are complete, add the following sentence to php. ini:

Extension = mongo. so

7. restart php-fpm or web service and check phpinfo. if you have mongoDB, congratulations, the installation is successful.



The execution result is as follows:

Processing ING:

PHP Api Version: 20041225

Zend Module Api No: 20060613

Zend Extension Api No: 220060519



After running, the./configure script is generated. at this time, we run the./configure script for configuration.

./Configure -- with-php-config =/usr/local/php/bin/php-config

-- With-php-config indicates the path of the configuration script php-config.



The preceding command runs in a correctly configured environment and the result is as follows:



Creating libtool

Appending configuration tag "CXX" to libtool

Configure: creating./config. status

Config. status: creating config. h



In this case, make is used to compile the extension.
Make & make install

The correct compilation and execution results are as follows:



Build complete.

Don't forget to run 'Make test '.




Installing shared extensions:/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/



After editing, add a line to your php. ini file.
Extension = mongo. so
The default php INI file is
/Usr/local/php/etc/php. ini
Restart your web server or php-fpm and print phpinfo. if you see the mongo entry table, the mongodb extension is successfully installed.

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.