The following content is reproduced from http://be-evil.org/post-284.html
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/
Therefore, the following paths must be changed.
Server Environment cent OS 5.6 32-bit, 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.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 the compiling extension environment. Here is the introduction of phpize.
/Usr/local/PHP/bin/phpize
The execution result is as follows:
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:
In this case, make is used to compile the extension.
Make & make install
The execution result of correct compilation is as follows (the last few lines of compilation output)
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 following content, congratulations! MongoDB extension has been installed successfully.