# 如果缺少php_json.h需要更新php版本或者安装json库
# [php]
tar -zxvf php-5.4.17.tar.gz
cd php-5.4.17
./configure --prefix=/usr/local/php_5.4.17 --with-apxs2=/usr/local/apache2/bin/apxs --enable-track-vars --with-xml --with-MySQL
make
make install
wget http://pecl.php.net/get/mongo-1.5.2.tgz
tar zxf mongo-1.5.2.tgz
cd mongo-1.5.2
/usr/local/php_5.4.17/bin/phpize
# 在需要扩展编译的PHP模块目录中进行/usr/local/php/bin/phpize 否则会报错 “
# Cannot find config.m4.
# Make sure that you run '/usr/local/php/bin/phpize' in the top level source directory of the module
# 运行后执行结果如下:
# Configuring for:
# PHP Api Version: 20041225
# Zend Module Api No: 20060613
# Zend Extension Api No: 220060519
./configure --with-php-config=/usr/local/php_5.4.17/bin/php-config
make
make install
echo "extension=mongo.so" >> /usr/local/php_5.4.17/etc/php.ini
# 正确编译执行结果如下:
# Build complete.
# Don't forget to run 'make test'.
转载于:https://my.oschina.net/mrytsr/blog/292968