OSX上带有Homebrew的PHP72 MongoDB驱动程序 [英] PHP72 MongoDB driver with Homebrew on OSX

查看:96
本文介绍了OSX上带有Homebrew的PHP72 MongoDB驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题可能表明我对Homebrew在MongoDB方面存在误解:

I have a question that might point to a misunderstanding I have with Homebrew in relation to MongoDB:

我正在Mac OSX 10.12.6(Sierra)上使用PHP 7.2.1(我要使用)运行XAMPP(版本).我安装了MongoDB,并创建了配置和数据存储文件夹.在命令行上运行正常(当通过终端使用mongod和mongodb时).

I am running XAMPP (version) with PHP 7.2.1 (which I want to use) on Mac OSX 10.12.6 (Sierra). I installed MongoDB and created configuration and data storage folder. It runs fine on command line (when using mongod and mongodb by terminal).

现在,我想为PHP 7.2.1安装PHP驱动程序.我按照 http://php.net/manual/en/mongodb上的说明进行操作.installation.homebrew.php 并将它们修改为7.2版,因此:

Now, I want to install the PHP driver for PHP 7.2.1. I followed the instructions on http://php.net/manual/en/mongodb.installation.homebrew.php and adapted them to version 7.2, therefore:

$ brew tap homebrew/homebrew-php
$ brew install php72-mongodb

这将在/usr/local/Cellar中创建一个php72和php72-mongodb文件夹.但是,我原来的(基于XAMPP的)PHP在/Applications/XAMPP/中,那里的php在/Applications/XAMPP/etc/php.ini中.

this creates a php72 and a php72-mongodb folder in /usr/local/Cellar. However, my original (XAMPP based) PHP is in /Applications/XAMPP/ and the php there is in /Applications/XAMPP/etc/php.ini.

,只需添加:

extension="/usr/local/opt/php72-mongodb/mongodb.so"

不会成功.添加此扩展后,Apache将不再启动. /Applications/XAMPP/logs/php_error.log显示以下错误:

won't do the trick. After adding this extension, Apache won't start any more. /Applications/XAMPP/logs/php_error.log shows the following error:

[27-Feb-2018 13:11:59 UTC] PHP Warning:  
PHP Startup: Unable to load dynamic library 'mongodb.so' 
(tried: /Applications/XAMPP/xamppfiles/lib/php/extensions
/no-debug-non-zts-20170718/mongodb.so 
(dlopen(/Applications/XAMPP/xamppfiles/lib/php/extensions/
no-debug-non-zts-20170718/mongodb.so, 9): image not found), 
/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-
20170718/mongodb.so.so 
(dlopen(/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-
non-zts-20170718/mongodb.so.so, 9): image not found)) in Unknown on 
line 0

在现有的XAMPP安装中包含/连接刚刚安装的驱动程序的正确方法是什么?我需要以某种方式告诉Homebrew我的XAMPP安装在哪里吗?

What is the correct way to include/connect the driver I just installed with my existing XAMPP installation? Do I need to tell Homebrew somehow where my XAMPP install is?

鉴于我在Homebrew中也有一个php文件夹(和我的/usr/local/opt文件夹),表明我现在有第二个PHP安装.这是应该的样子吗?

Given that I also have a php folder in my Homebrew (and my /usr/local/opt folder) indicates that I have a second PHP installation right now. Is this the way it is supposed to be?

推荐答案

MAMP附带的PHP版本不完整,您需要获取完整版本此处.

The PHP version coming with MAMP is incomplete, you need to get the full version here.

然后,将本地include文件夹替换为该下载版本的include文件夹.

Then, replace your local include folder, with the include folder of that downloaded version.

转到终端并运行./configure,这将安装MAMP php的完整副本.

Go to your terminal and run ./configure, this will install full copy of your MAMP php.

现在您已经准备好PHP目录,请安装mongodb扩展名:

Now that you have prepared the PHP directory, install the mongodb extension:

cd /Applications/MAMP/bin/php/php(your version ex: 7.2)/bin

然后运行pecl以安装mongodb扩展名

and then run pecl to install mongodb extension

./pecl install mongodb

现在您已经安装了mongodb,但是您的php应该知道这一点.

Now you have installed mongodb but your php should know this.

转到php.ini文件并搜索;Extension 在此下方添加extension=mongodb.so

Go to php.ini file and search for ;Extension Under this add extension=mongodb.so

然后重新启动服务器,一切顺利,希望对您有所帮助!

Then restart your server and you are good to go, I hope this helps!

这篇关于OSX上带有Homebrew的PHP72 MongoDB驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆