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.