简体   繁体   English

Azure PHP Mongodb扩展

[英]Azure PHP Mongodb extension

I cannot manage to setup the database on Azure Web App. 我无法在Azure Web App上设置数据库。 I followed the instructions exactly from https://azure.microsoft.com/en-us/documentation/articles/web-sites-php-configure/ (section 4). 我完全按照https://azure.microsoft.com/zh-CN/documentation/articles/web-sites-php-configure/ (第4节)中的说明进行操作。 The error I get on my web app is: 我在Web应用程序上遇到的错误是:

Fatal error: Class 'MongoClient' not found in D:\\home\\site\\wwwroot\\index.php on line 42 致命错误:在第42行的D:\\ home \\ site \\ wwwroot \\ index.php中找不到类'MongoClient'

I downloaded the DLL of MongoDB named php_mongo-1.6.8-5.4-vc9-nts.dll, and renamed it to php_mongo.dll, moved it to a directory bin, and updated the web app settings accordingly (PHP_EXTENSIONS=bin/php_mongo.dll). 我下载了名为php_mongo-1.6.8-5.4-vc9-nts.dll的MongoDB DLL,并将其重命名为php_mongo.dll,将其移至目录bin,并相应地更新了Web应用程序设置(PHP_EXTENSIONS = bin / php_mongo。 dll)。

I tried the following solution, with no success: Enable mongo PHP extension in Microsoft Azure Websites 我尝试了以下解决方案,但没有成功: 在Microsoft Azure网站中启用mongo PHP扩展

I tested the function for configuring PHP extensions via App Settings which is mentioned in official article at section Configure via App Setting . 我测试了通过“应用程序设置”配置PHP扩展的功能,这在官方文章“ 通过应用程序设置配置”部分中提到。

The following images are my configuration: 以下图像是我的配置:

Test project directory: 测试项目目录: 在此处输入图片说明

App Settings: 应用设置: 在此处输入图片说明

And check PHP runtime in phpinfo : 并在phpinfo检查PHP运行时: 在此处输入图片说明

It worked fine for me by following official article. 通过关注官方文章对我来说效果很好。

Please check whether you had missed any steps, or had completely upload the extension file, and check whether the extension file is match your PHP version. 请检查您是否错过了任何步骤,或者是否已完全上传扩展文件,并检查该扩展文件是否与您的PHP版本匹配。 You also can use FTP or kudu console to check your extension file. 您还可以使用FTP或Kudu控制台来检查扩展文件。

Any concern, please feel free to let me know. 如有任何疑问,请随时告诉我。

Well, the problem was pretty stupid. 好吧,这个问题很愚蠢。 I hope Microsoft will fix it someday. 我希望微软有一天会修复它。

They said the relative path is the root directory, but its not, its the deployment directory. 他们说相对路径是根目录,而不是根目录,即部署目录。

So on the App Settings I had to specify PHP_EXTENSIONS=D:\\home\\bin\\php_mongo.dll 因此,在“应用程序设置”上,我必须指定PHP_EXTENSIONS = D:\\ home \\ bin \\ php_mongo.dll

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

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