问题描述
第一件事:我的任务是在 Azure 上部署一个 Drupal 网站.
First things first: I was given the task to deploy a Drupal website on Azure.
在本地,我使用运行 Apache 的 OS X,一切正常.将项目部署到 Azure 时,出现错误.经过一些调试后,我将错误隔离到这段代码中:
Locally I use OS X running Apache and everything works ok. When I deploy the project to Azure, I get an error. After some debugging I isolated the error to this snippet of code:
private function getToken(){
$ch = curl_init($this->host . $this->clientId . "&client_secret=" . $this->clientSecret);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',));
$response = json_decode(curl_exec($ch));
curl_close($ch);
$token = $response->access_token;
dvm($response, $name = NULL);
return $token;
}
dvm()
是一个 Drupal Devel 函数,但足以说它有点像 Drupal 的 print_r
.
dvm()
is a Drupal Devel function, but suffice to say that's sort of print_r
for Drupal on steroids.
我遇到的问题是,无论出于何种原因,$result
都会返回 NULL
.当我在本地机器和 Linux/Debian 机器上运行相同的代码时,一切都按预期工作(由于 curl
,我得到了一个对象).
The problem I'm getting is that for whatever reason, $result
is coming back NULL
. When I run the same code on my local machine and on a Linux/Debian box, all worked as expected (I get an Object as a result of the curl
).
由此得出的结论是,Azure 不喜欢这段代码中的某些内容.问题是找出什么.有什么想法吗?
This leads to the conclusion that Azure is not liking something in this piece code. The problem is finding out what. Any ideas?
推荐答案
对于 prod 环境,display_errors
在 Azure Web Apps 上的 PHP 运行时设置为 off
.我们可以通过更改内置的 PHP 配置来打开调试设置.
For a prod environment, display_errors
is set off
in PHP runtime on Azure Web Apps. We can open the setting for debugging via change the build-in PHP configurations.
以下是简单的步骤:
1、在你的根目录添加一个.user.ini
文件.
1, Add a .user.ini
file to your root directory.
2、使用与在 php.ini
文件中相同的语法将配置设置添加到 .user.ini 文件.根据您的要求,您的 .user.ini
文件将包含以下文本:
2, Add configuration settings to the .user.ini file using the same syntax you would use in a php.ini
file. With your demand, your .user.ini
file would contain this text:
display_errors = On
3、部署您的网络应用程序.
3, Deploy your web app.
4、重启网络应用.
您可以阅读官方指南 了解更多信息.
You can read official guide for more information.
此外,我们可以登录我们网站的 Kudu 控制台来管理我们的网站.Kudu 控制台的 URL 应该是:https://{your_web_site_name}.scm.azurewebsites.net
,然后单击 Tools
=> Diagnostic dump
下载诊断日志.
Furthermore, we can login in the Kudu console of our websites to manage our sites. The URL of Kudu console should be like: https://{your_web_site_name}. scm.azurewebsites.net
, and click Tools
=> Diagnostic dump
to download the diagnostic logs.
此外,我们可以使用 WebMatrix 直接修改您在 Azure Web 应用程序上的代码.
Additional, we can use WebMatrix to directly modify your code on Azure Web Apps.
这篇关于如何在 MS Azure 中调试 PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!