简体   繁体   English

无法将PHP连接到Google Cloud中的MongoDB

[英]Can't connect PHP to MongoDB in Google Cloud

I'm trying to connect my PHP app to MongoDB in Google Cloud but I'm getting an error. 我正在尝试将PHP应用程序连接到Google Cloud中的MongoDB,但出现错误。 Those are the steps I followed. 这些是我遵循的步骤。

1- MongoDB is installed and working with Bitnami's launcher 1- MongoDB已安装并与Bitnami的启动器一起使用

2- I installed mongodb PHP extension 2-我安装了mongodb PHP扩展

sudo apt-get install mongodb

在此处输入图片说明

3- I created a php.ini file in the root (same directory as app.yaml) and added the extension 3-我在根目录(与app.yaml相同的目录)中创建了一个php.ini文件,并添加了扩展名

extension=mongodb.so

Error 错误

Neither phpinfo or extension_loaded shows mongodb extension as loaded in my server, therefore, I can't connect. phpinfoextension_loaded都没有显示mongodb扩展名已加载到我的服务器中,因此,我无法连接。 Can anyone help me to figure out what am I missing? 谁能帮助我找出我想念的东西吗?

I already found the solution. 我已经找到了解决方案。 The problem, as Alex suggested in his comment, was that I was installing the server and not the PHP driver. 正如Alex在他的评论中建议的那样,问题是我正在安装服务器而不是PHP驱动程序。

That made the trick: 这就是窍门:

sudo apt-get install php-mongodb

Correct way to add mongodb extension is as follows(see this ): 添加MongoDB的扩展正确的方法是如下(见 ):

extension = "mongo.so"

Also as Alex Blex commented, sudo apt-get install mongodb installs the mongodb itself. 同样正如Alex Blex所评论的那样, sudo apt-get install mongodb会自行安装mongodb。 My understanding is that you don't need to install neither that nor the extension, Google App Engine Flex environment already supports this via php.ini configuration. 我的理解是,您既不需要安装扩展程序也不需要安装扩展程序,Google App Engine Flex环境已经通过php.ini配置支持此功能。

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

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