Enable PHP Extension (php_odbc.dll) on Azure

牧云@^-^@ 提交于 2020-03-04 18:43:36

问题


I have started working with Azure and testing connectivity to an Microsoft SQL Database. I would like to utilize our current php_odbc.dll extension instead of using the PDO approach.

  $query = "SELECT * FROM TABLE ";          
  //perform the query 
  $result=odbc_exec($conn, $query); 

I have performed the steps for adding an extension by configuring via App Setting and configuring via ini settings. Both ways cause my main index page to throw a 500 error. My main index.php only includes the phpinfo(); function for testing.

https://docs.microsoft.com/bs-latn-ba/azure/app-service/web-sites-php-configure#configure-via-app-setting

Question: How do I enable the php_odbc.dll ext on Azure? PHP version is 7.3


回答1:


I see you were using Azure WebApp for Windows to deploy your PHP app with Azure SQL Database connection by php_odbc.dll.

As I known, Azure WebApp for Windows has been installed several versions of PHP runtime with many extensions, which include PHP 7.3 that is under the path D:\Program Files (x86)\PHP as the figure below and I checked php_odbc.dll whether be exists via Kudo console https://<your webapp name>.scm.azurewebsites.net/DebugConsole

Then, I moved to v7.3 to view the php.ini file to check the php_odbc.dll extension whether be enabled.

As the figure above, you can see there is no php_odbc declared in php.ini, so it's not enabled default. And Azure regulates all files and directories under D:\ (except D:\home) that can not be changed by customers, so to try to edit php.ini to enable php_odbc will cause error issue.

So the solution is to refer to the section How to: Enable extensions in the default PHP runtime of the offical document Configure PHP in Azure App Service as the figure below to enable a default existing extension.

By default, there may not be a directory named ini in the path D:\home\site which need to be created by yourself, and then to create a file named extensions.ini under it and edit it to add the extension name or the absoluted path of php_odbc.

; Enable Extensions
extension=php_odbc
; Or use its absoluted path, such as for 32bit platform
; extension=D:\Program Files (x86)\PHP\v7.3\ext\php_odbc.dll

After restart your Azure WebApp, you can try your PHP page again.



来源:https://stackoverflow.com/questions/59795602/enable-php-extension-php-odbc-dll-on-azure

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!