The compilation of PHP MONGO module
To download the current stable stable version from Http://pecl.php.net/package/mongo, the latest stable release is 1.5.2 and the installation steps are as follows:
The code is as follows |
Copy Code |
# wget Http://pecl.php.net/get/mongo-1.5.2.tgz # tar ZXVF mongo-1.5.2.tgz # CD mongo-1.5.2 #/usr/bin/phpize #./configure–with-php-config=/usr/bin/php-config # Make && make install
|
Note: When there is no phpize tool, the tool can be installed through yum-y install Php-devel.
Second, the expansion of PHP configuration
When you are done, add the following in/etc/php.ini:
The code is as follows |
Copy Code |
Extension=mongo.so
|
When you are done, use the php-m view to find the error:
The code is as follows |
Copy Code |
# Php-m|grep MONGO /usr/lib64/php/modules/mongo.so:undefined Symbol:php_json_encode in Unknown on line 1
|
The online query found that it is necessary to rely on the json.so module, after viewing the/usr/lib64/php/modules/directory already exists json.so module. The reason for the error is that the json.so is loaded after mongo.so. The configuration of the following JSON was found in the/etc/php.ini, and the discovery did not exist. A Json.ini file was found in the/ETC/PHP.D directory.
The code is as follows |
Copy Code |
# Cat/etc/php.d/json.ini ; Enable JSON Extension Module Extension=json.so
|
Know the reason, also according to gourd painting scoop, will just in/etc/php.ini MONGO configuration Delete, in the/etc/php.d/directory add Mongo.ini, content for extension=mongo.so, configuration completed after use Php-m|grep MONGO detection was found to be normal.
Note: There are some ways to do this online by deleting the/etc/php.d/json.ini file and adding the JSON module's configuration to the MONGO module configuration in the/etc/php.ini file. Although this method can be, it is not recommended, because the above method will automatically look at the dependencies between the modules, and then decide the order of loading. The same can be resolved automatically if the situation is encountered by other modules.