使用 MONGO 驱动程序编译 PHP 5.4.5


compile php 5.4.5 with mongo driver

现在我已经在我的 Ubuntu PC 上通过 apt-get 安装了 php 5.3.*,但我需要使用 5.4.5 来解决一些问题。根据这个原因,我尝试使用mongo驱动程序编译并安装新版本php 5.4.5到单独的位置:我做了后续步骤:

sudo su
cd /opt
tar xfz php-5.4.5.tar.gz
cd php-5.4.5
./configure --prefix=/opt/php545 --enable-phar --with-config-file-path=/opt/php545/php.ini
make & make install

在上述命令之后,我已经有了 php 工作:

/opt/php545/bin/php -v
PHP 5.4.5 (cli) (built: Aug 15 2012 09:04:56) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies

之后我做了接下来:

/opt/php545/bin/pecl install mongo

它回报了我

Build process completed successfully
Installing '/opt/php545/lib/php/extensions/no-debug-non-zts-20100525/mongo.so'
install ok: channel://pecl.php.net/mongo-1.2.12
configuration option "php_ini" is not set to php.ini location
You should add "extension=mongo.so" to php.ini

我在/opt/php545/php.ini 中添加了下一行

extension=/opt/php545/lib/php/extensions/no-debug-non-zts-20100525/mongo.so

但是 MONGO 没有作为模块加载:

/opt/php545/bin/php -m | grep mongo
!!!Nothing here!!!

我做错了什么?

附注:

 /opt/php545/bin/php -i | grep php.ini 

返回

Configuration File (php.ini) Path => /opt/php545/php.ini

(PHP.ini设置正确)

PHP config 不接受扩展行的绝对路径,请使用 extension_dir。

不从 php.ini 加载扩展名,从 ini 文件加载,解析如下:

 nano /usr/local/php-5.x.xx/php.d/mongo.ini

x.xx 是你的 PHP 版本。

然后加载扩展:

 ;Enable mongo extension module
 extension=mongo.so
 mongo.default_port=27017

使用 Ctrl + O 保存并关闭白色 CRTL + X

然后重新启动服务:

 service php-fpm restart 
 service httpd restart

php-fpm 如果它有

所以你应该已经加载了。