简体   繁体   English

无法使PHP加载mongo.so扩展

[英]Can't get PHP to load mongo.so extension

I've tried building the library with PECL, I've tried downloading it from github. 我试过用PECL构建库,试过从github下载。 I've tried MAMP, I've tried XAMPP. 我尝试过MAMP,我尝试过XAMPP。 I always get the same error: 我总是得到相同的错误:

PHP Warning: PHP Startup: Unable to load dynamic library '/Applications/XAMPP/xamppfiles/lib/php/php-5.3.1/extensions/no-debug-non-zts-20090626/mongo.so' - dlopen(/Applications/XAMPP/xamppfiles/lib/php/php-5.3.1/extensions/no-debug-non-zts-20090626/mongo.so, 9): no suitable image found. PHP警告:PHP启动:无法加载动态库'/Applications/XAMPP/xamppfiles/lib/php/php-5.3.1/extensions/no-debug-non-zts-20090626/mongo.so'-dlopen(/ Applications /XAMPP/xamppfiles/lib/php/php-5.3.1/extensions/no-debug-non-zts-20090626/mongo.so,9):找不到合适的图片。 Did find:\\n\\t/Applications/XAMPP/xamppfiles/lib/php/php-5.3.1/extensions/no-debug-non-zts-20090626/mongo.so: unknown required load command 0x80000022 in Unknown on line 0 确实找到了:\\ n \\ t / Applications / XAMPP / xamppfiles / lib / php / php-5.3.1 / extensions / no-debug-non-zts-20090626 / mongo.so:未知的所需加载命令0x80000022在未知的第0行

(Paths differ depending on XAMPP or MAMP) (路径因XAMPP或MAMP而异)

I'm running OS 10.5.8. 我正在运行OS 10.5.8。 Any ideas? 有任何想法吗?

Just going off of the error message there, I can tell you this is an architecture-related issue (for example, see this ). 只是从那里看到错误消息,我可以告诉您这是一个与体系结构相关的问题(例如,参见this )。 XAMPP is still 32-bit only according to this question on their FAQ , and PECL will try to build extensions as 64-bit by default. 仅根据其FAQ上的此问题, XAMPP仍为32位,并且PECL将尝试默认将扩展构建为64位。

However both MAMP and MAMP Pro come in both 32 and 64-bit binaries as of 2.0 1 . 但是,从2.0 1开始,MAMP和MAMP Pro都提供32位和64位二进制文​​件。

However, the question is whether your Mac has a 64-bit processor, and whether it runs the 64-bit OS X by default. 但是,问题是Mac是否具有64位处理器,以及默认情况下是否运行64位OSX。 This Apple support article offers a guide on how to determine which Mac you have. 此Apple支持文章提供了有关如何确定您拥有的Mac的指南。 For example, if you have a Macbook Pro from 2008-2010, it might run the 32-bit kernel by default, but (see the article) you can set it to run the 64-bit kernel instead. 例如,如果您拥有2008-2010年的Macbook Pro,则它可能默认运行32位内核,但是(请参阅文章)您可以将其设置为运行64位内核。

Your quickest path to your goal is probably to build mongo.so for 32-bit though. 达到目标的最快途径可能是为32位构建mongo.so。 This article on using MAMP/PECL to install PHP extensions says that with PECL it should be as simple as this: 关于使用MAMP / PECL安装PHP扩展的这篇文章说,使用PECL,它应该像这样简单:

CFLAGS="-arch i386" ./pecl install

If that doesn't work, you can try a manual installation, passing 32-bit flags to configure. 如果这不起作用,则可以尝试手动安装,并传递32位标志进行配置。 See this question for memcached.so installation for methods that will probably work for you. 有关可能适合您的方法,请参阅有关memcached.so安装的问题

This should work (based on above and manual installation instructions for the Mongo driver on php.net ): 这应该可以工作(基于上面和php.net上Mongo驱动程序的手动安装说明 ):

tar zxvf mongodb-mongodb-php-driver-<commit_id>.tar.gz
cd mongodb-mongodb-php-driver-<commit_id>
phpize
MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" CXXFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" LDFLAGS="-arch i386 -arch x86_64 -bind_at_load" ./configure
sudo make install

...then refer to the php.net link above for the rest of the manual installation steps (ie adding the extension in your php.ini). ...然后,请参阅上面的php.net链接以获取其余的手动安装步骤(即在php.ini中添加扩展名)。

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

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