无法使用MongoDB扩展运行PHP(PHP 5.3.8,操作系统:Centos 5.4)


Failed to run PHP with MongoDB Extension (PHP 5.3.8 , OS: Centos 5.4)

我在运行PHP的MongoDB扩展时遇到问题

阅读本文末尾的解决方案

我使用3种不同的方法成功安装了它,但它没有在phpinfo()中显示扩展

1-在php.ini中使用pecl安装mongo(它成功了,并要求我添加extension=mongo.so)2-通过下载源代码进行编译。3-来自于安装php-pecl-mongo

所有方法都成功了,没有错误,但当我运行phpinfo时,我没有看到Mongo扩展被加载,当我试图调用它时,它要求安装扩展。

我如何调试这个问题(即在哪里可以找到这样的日志)

如何查找Mongo与PHP 5.3.8的兼容性信息?

这是我在安装结束时得到的:

注意:我确信我将mongo.so文件复制到了php的扩展路径,因为我正在使用同一目录中的其他扩展,并且它们正在工作

Libraries have been installed in:
   /sources/mongo/mongodb-mongo-php-driver-d7c19b8/modules
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Installing shared extensions:     /usr/local/lib/php/extensions/no-debug-non-zts                                                -20060613/
-bash-3.2# cp /usr/local/lib/php/extensions/no-debug-non-zts-20060613/mongo.so /  

修复-->问题是我的phpapi与php的版本不同,即php-devel/php5-devel需要更新

手动编译模块时,必须将其复制到PHP知道在哪里查找自定义模块的路径。

从cli,尝试以下命令:

php -i | fgrep -i configure

你应该看到这样一个选项:

--with-config-file-scan-dir=/bridge/to/nowhere

确保在编译模块后,将模块从mongo源目录复制到/bridge/to/none目录,这样PHP就可以获取它。

如果运气好的话,它应该在你做php -m时列出。

如果将php.ini文件中的"extension=mongo.so"行更改为:,会发生什么

extension=/usr/local/lib/php/extensions/no-debug-non-zts-20060613/mongo.so

php启动时,是否会产生任何错误消息?如果没有,请验证php -i |grep -e 'Loaded Configuration File'是否显示了预期的php.ini文件。

mongodbphp扩展应该可以很好地与phpv5.3.8(和php-fpm)配合使用。