Skip to content

Latest commit

 

History

History
46 lines (33 loc) · 2.58 KB

File metadata and controls

46 lines (33 loc) · 2.58 KB
title Step 1: Configure Environment for PHP
description Step 1 of this getting started guide involves installing PHP, the Microsoft ODBC Driver for SQL Server, and configuring your development environment.
author David-Engel
ms.author davidengel
ms.reviewer randolphwest
ms.date 03/25/2026
ms.service sql
ms.subservice connectivity
ms.topic how-to
ms.custom
linux-related-content

Step 1: Configure environment for PHP development

[!INCLUDE Driver_PHP_Download]

To connect to SQL Server from a PHP application, you need the following components installed in this order:

  1. PHP runtime: Download and install PHP from php.net (Windows) or use your system package manager (Linux/macOS).

  2. Microsoft ODBC Driver for SQL Server: The PHP drivers require the ODBC driver. Download it from Download ODBC Driver for SQL Server.

  3. Microsoft Drivers for PHP for SQL Server: Download the drivers from Download the Microsoft Drivers for PHP for SQL Server. For more information on version compatibility, see System requirements for the Microsoft Drivers for PHP for SQL Server.

  4. Web server (optional): Configure IIS (Windows) or Apache/Nginx (Linux/macOS) if you're building web applications.

Windows

  1. Download and install PHP — use the Thread Safe (TS) version for IIS, or Non-Thread Safe (NTS) for Apache or CLI.

  2. Download and install the ODBC Driver for SQL Server.

  3. Download the Microsoft Drivers for PHP for SQL Server and extract the .dll files to your PHP extensions directory.

  4. Enable the driver by adding the following lines to your php.ini file:

    extension=php_sqlsrv.dll
    extension=php_pdo_sqlsrv.dll
  5. Verify the installation by running php -m and checking that sqlsrv and pdo_sqlsrv appear in the list.

For detailed instructions, see Loading the Microsoft Drivers for PHP for SQL Server. To configure IIS, see Download the Microsoft Drivers for PHP for SQL Server.

Linux and macOS

For step-by-step instructions on installing PHP, the ODBC driver, and the PHP drivers on Linux and macOS, see Linux and macOS Installation Tutorial for the Microsoft Drivers for PHP for SQL Server.