CentOS 5.7 - 安装PHP MongoDB扩展

查看官方文档,只需要执行如下命令即可:

sudo pecl install mongo

但在我的机器上,这种方法无法执行成功。出现了以下错误:

pecl install mongo
downloading mongo-1.2.10.tgz ...
Starting to download mongo-1.2.10.tgz (86,463 bytes)
.....................done: 86,463 bytes
36 source files, building
running: phpize
Configuring for:
PHP Api Version:         20041225
Zend Module Api No:      20060613
Zend Extension Api No:   220060519
/usr/bin/phpize: /tmp/mongo/build/shtool: /bin/sh: bad interpreter: Permission denied
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.

ERROR: `phpize' failed

于是就自己安装,步骤如下:

* 下载Mongo扩展包:

mkdir  /home/mongo_php
cd /home/mongo_php
pecl download mongo

我下载的版本是 mongo-1.2.10.tgz

* 解压文件并进入mongo目录,运行phpize命令,生成configure脚本:

tar zxf mongo-1.2.10.tgz
cd mongo-1.2.10
phpize

执行配置与安装:

./configure --with-php-config=/usr/bin/php-config
make
make install

安装成功后,显示安装成功后的路径

Installing shared extensions:     /usr/lib/php/modules/

编辑 /etc/php.ini,添加mongo.so

vi /etc/php.ini

extension=mongo.so

:wq 保存退出后,重启Apache

运行命令查看是否执行成功

php -i | grep mongo

或者在 phpinfo() 的输出中查看

 

posted @ 2012-04-23 12:19  Old  阅读(2485)  评论(0编辑  收藏  举报