How to install PHP Extension SQLSRV on Azure App Service (PHP 8.2 / Linux)?

66 views Asked by At

Does anyone know how to install the PHP extension "SQLSRV" on an Azure App Service with PHP version 8.2 and Linux OS?

Thank you in advance

1

There are 1 answers

0
Pravallika KV On

I could install the SQLSRV extension for PHP 8.2 on Azure App Service running Linux with the below steps:

  1. Enable SSH Access to your Azure App Service:
  • Navigate to Portal=>App Service=>Settings=>Configuration=>General settings and Turn SSH On.

enter image description here

  1. Navigate to Development Tools=>SSH=>Go and run the below commands:
  • Install Required Packages:
sudo su 
add-apt-repository ppa:ondrej/php -y 
apt-get update apt-get install php8.2 -y --allow-unauthenticated
  • Install Prerequisites:
sudo apt-get install unixodbc-dev
sudo apt-get install -y libgssapi-krb5-2

enter image description here

  • Download and Install SQL Server ODBC Driver:

Note: SQLSRV extension requires the SQL Server ODBC Driver.

1. curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc
2. curl https://packages.microsoft.com/config/debian/12/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list 
3. sudo apt-get update 
4. sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18
  • Install PHP SQLSRV Extension:
sudo pecl install sqlsrv
sudo pecl install pdo_sqlsrv

enter image description here

enter image description here

  1. Enable the Extension:
extension=sqlsrv.so
extension=pdo_sqlsrv.so