简体   繁体   English

使用MongoDB Extension运行PHP失败(PHP 5.3.8,操作系统:Centos 5.4)

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

I have a problem on running PHP's MongoDB extensions 我在运行PHP的MongoDB扩展时遇到问题

Read the solution at the end of this post 阅读本文末尾的解决方案

I successfully installed it using 3 different methods but it doesn't show the extension in phpinfo() 我使用3种不同的方法成功安装了它,但它没有在phpinfo()中显示扩展名

1-Using pecl install mongo ( it succeeded and asked me to add extension=mongo.so) in php.ini 2-By downloading the source the compiling it. 1 - 使用pecl install mongo(它成功并要求我在php.ini中添加extension = mongo.so)2 - 通过下载源代码编译它。 3-From yum installing php-pecl-mongo 3 - 从yum安装php-pecl-mongo

All methods succeed without errors but when I run phpinfo I don't see the Mongo extension loaded and when I try to call it asks for installing the extension. 所有方法都成功没有错误,但是当我运行phpinfo时,我没有看到Mongo扩展加载,当我尝试调用它时要求安装扩展。

How do I debug this issue (ie Where can I find such logs) 如何调试此问题(即我在哪里可以找到此类日志)

And how do I Find info about Mongo's compatibility with PHP 5.3.8 ? 我如何找到有关Mongo与PHP 5.3.8的兼容性的信息?

This is what I get at the end of the installation : 这是我在安装结束时得到的:

Notice: I'm sure that I copied the mongo.so file to the extension path of php as I'm using other extension from the same dir and they're working 注意:我确定我将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 /  

Fixed --> the issue was that my php api wasn't the same version as PHP ie php-devel/php5-devel needed to be updated. 修复 - >问题是我的php api与PHP的版本不同,即php-devel / php5-devel需要更新。

When you compile a module manually you have to copy it to a path which PHP knows where to look for custom modules. 手动编译模块时,必须将其复制到PHP知道在哪里查找自定义模块的路径。

From the cli, try this command: 从cli中,尝试以下命令:

php -i | fgrep -i configure

You should see an option like: 您应该看到如下选项:

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

Make sure, after you compile the module, that you copy the module from the mongo source directory, to the /bridge/to/nowhere directory, so PHP can pick it up. 在编译模块之后,确保将模块从mongo源目录复制到/ bridge / to / nowhere目录,以便PHP可以将其拾取。

With any luck, it should be listed when you do a php -m . 运气好的话,应该在你做php -m时列出。

What happens if you change the ' extension=mongo.so ' line in your php.ini file to: 如果将php.ini文件中的“ extension=mongo.so ”行更改为:

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

When php starts up, does it produce any error message? 当php启动时,它是否会产生任何错误消息? If not, please verify that php -i |grep -e 'Loaded Configuration File' shows the expected php.ini file. 如果没有,请验证php -i |grep -e 'Loaded Configuration File'显示了预期的php.ini文件。

The mongodb php extension should work just fine with php v5.3.8 (and php-fpm). mongodb php扩展应该可以正常使用php v5.3.8(和php-fpm)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM