如何在 OSX 上为 XAMPP 安装 PHP MongoDB 驱动程序?
我在命令终端上输入了以下命令,以便在我的 Macbook Pro 上的 XAMPP 上将MongoClient"与 PHP 一起使用:
I entered the following commands on my command terminal in order to use the 'MongoClient' with PHP on XAMPP on my Macbook Pro:
- brew 安装 wget
- brew 安装自动配置
- sudo/Applications/XAMPP/xamppfiles/bin/pecl install mongo
- 将 extension=mongo.so 添加到 php.ini/Applications/XAMPP/xamppfiles/etc
- 重新启动 Apache
但是,我没有运气.我不断收到此错误:致命错误:第 5 行的/Applications/XAMPP/xamppfiles/htdocs/xampp/index.php 中找不到类 'MongoClient'
However, I have had no luck. I keep getting this error: Fatal error: Class 'MongoClient' not found in /Applications/XAMPP/xamppfiles/htdocs/xampp/index.php on line 5
我有点沮丧,因为我真的不知道还能尝试什么.有什么建议吗?
I'm getting kind of frustrated because I don't really know what else to try. Any advice?
推荐答案
需要启动mongod
酿造更新
brew 安装 mongodb
brew install mongodb
mkdir -p/data/db
mkdir -p /data/db
mongod --dbpath/data/db
mongod --dbpath /data/db
在第一次运行mongod
之前,确保运行mongod的用户账号对/有
目录.read
和write
权限data/db
Before running mongod
for the first time, ensure that the user account running mongod has read
and write
permissions for the /data/db
directory.
安装 MongoDB PHP 驱动
Install MongoDB PHP driver
brew install php56-mongo
brew install php56-mongo
或
sudo pecl 安装 mongo
sudo pecl install mongo
相关文章