Add MongoDB extension for PHP in Linux

Source: Internet
Author: User

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.tgzcd 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 the following error occurs:
  1. Processing ing:
  2. Php api version: 20041225
  3. Zend module api no: 20060613
  4. Zend extension api no: 220060519
  5. Cannot find Autoconf. Please check your Autoconf installation and
  6. $ Php_autoconf environment variable. Then, rerun this script
Problem: M4 and Autoconf can be downloaded without installing 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 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.

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.