为什么我的 twilio Web 应用程序可以在 XAMPP 中运行,但不能在 AZURE 中运行 [英] Why does my twilio web application work in XAMPP but not in AZURE

查看:27
本文介绍了为什么我的 twilio Web 应用程序可以在 XAMPP 中运行,但不能在 AZURE 中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 php 中创建了一个应用程序,它使用 twilio api 向人们发送文本.它在 XAMPP 中完美运行,但 php 代码不能在 Azure 中运行.每次我调用它时,我都会收到一条错误消息:加载资源失败:服务器响应状态为 500(内部服务器错误)".

I've created an application in php that sends texts out to people using the twilio api. It works perfectly in XAMPP but the php code doesn't run in Azure. Everytime I call it I get an error message saying "Failed to load resource: the server responded with a status of 500 (Internal Server Error)".

有没有一种方法可以解决这个问题而不必创建自己的虚拟服务器?

Is there a way I can solve this problem without having to create my own virtual server?

推荐答案

通常,当我们收到 500 响应时,这意味着我们在服务器脚本上遇到了一些错误.我们可以在 Azure Web 应用程序的 PHP 运行时中设置 display_errors=On 以便于故障排除.请参阅 https://azure.microsoft.com/en-in/documentation/articles/web-sites-php-configure/#how-to-change-the-built-in-php-configurations 了解详情.

Usually, when we get 500 response, it means we get some errors on server scripts. And we can set the display_errors=On in PHP runtime on our Azure Web Apps for easy troubleshooting. Refer to https://azure.microsoft.com/en-in/documentation/articles/web-sites-php-configure/#how-to-change-the-built-in-php-configurations for details.

并且您可以检查您在 Azure Web Apps 上的应用程序是否已成功安装 twilio lib.您可以利用composercomposer.json 中配置sdk,然后当您通过Git 将应用程序部署到Azure 时,Azure 服务将在composer 中安装依赖项.json 文件在部署任务期间自动生成.您可以利用 require 'vendor/autoload.php' 来加载所有依赖项.

And you may check whether your application on Azure Web Apps has successfully installed the twilio lib. You can leverage composer to configure the sdk in composer.json, then when you deploy your application to Azure via Git, Azure service will install the dependencies in composer.json file automatically during the deployment task. You can leverage require 'vendor/autoload.php' to load all the dependencies.

第一次测试时,出现如下错误:致命错误:未捕获的异常 Services_Twilio_TinyHttpException 消息 SSL 证书问题...

At the first time during the test, I got the following error: Fatal error: Uncaught exception Services_Twilio_TinyHttpException with message SSL certificate problem...

所以这也可能是你这边的问题,你可以在Azure Web Apps上的PHP中添加证书,请参考https://blogs.msdn.microsoft.com/azureossds/2015/06/12/verify-peer-certificate-from-php-curl-for-azure-apps/ 了解详细步骤.

So it may be the issue on your side too, you can add the certificate in PHP on Azure Web Apps, please refer to https://blogs.msdn.microsoft.com/azureossds/2015/06/12/verify-peer-certificate-from-php-curl-for-azure-apps/ for detailed steps.

否则,您可以简单地在 twilio lib 中编辑 TinyHttp.php:

Otherwise, you can simply edit TinyHttp.php in twilio lib:

在 $opts 数组中添加 CURLOPT_SSL_VERIFYPEER => FALSE.

add CURLOPT_SSL_VERIFYPEER => FALSE, at $opts array.

参考 Twilio PHP - SSL 证书:self证书链中的签名证书 用于同一问题.

Refer to Twilio PHP - SSL certificate: self signed certificate in certificate chain for the same issue.

这篇关于为什么我的 twilio Web 应用程序可以在 XAMPP 中运行,但不能在 AZURE 中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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