1

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?

David Makogon
  • 69,407
  • 21
  • 141
  • 189
Lana A
  • 23
  • 3
  • 1
    You will need to look at the error log and/or enable error reporting to see a ***concrete*** error message instead of the general "500" coverup. – deceze Mar 15 '16 at 12:51
  • You should edit your question to show the problematic code. Right now, you are showing nothing. Also, you might want to mention *where* you're running your code (VM? Web App? web/worker role?) – David Makogon Mar 15 '16 at 12:56

2 Answers2

1

They have many possibles:

  1. Your Azure running PHP in ISS Server, then you need convert your .htaccess file to web.config, simple, just go to website in IIS and on import your .htaccess file, IIS will convert your .htaccess in web.config.

  2. Permissions on folder you are running.

  3. PHP versions, check your PHP version on xampp and compare to PHP version on Azure. Your code can be compatible in your PHP Xampp but not in PHP Azure.

  4. Extensions PHP, it is possible that your xampp has extensions for PHP enable that your Azure not are enable, like file_info, etc...
Vinícius Medeiros
  • 2,763
  • 1
  • 11
  • 12
1

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.

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.

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

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.

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

add CURLOPT_SSL_VERIFYPEER => FALSE, at $opts array.

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

Community
  • 1
  • 1
Gary Liu
  • 13,758
  • 1
  • 17
  • 32