Install PHP drivers for Microsoft SQL Server on Ubuntu PHP 7.2

On Ubuntu 18.04 server running PHP 7.2, i want to install Microsoft SQL Server module for PHP. You can find PHP module for SQL server at

At the time of writing this PHP module only support PHP 7.4 and newer. SO i need to find older version that supported PHP 7.2. On checking release page, i found version 5.8.0 supported PHP 7.2

First install php7.2 dev package with

Instal php modules with pcel

During install, i got error

This is fixed with command

install pdo_sqlsrv with


Enabe PHP modules with

Restart Apache, now phpinfo() shows pdo_sqlsrv

But when accessing PHP script that connect to MS SQL server, i get error

This extension requires the Microsoft ODBC Driver for SQL Server to communicate with SQL Server. Access the following URL to download the ODBC Driver for SQL Server for x64

To fix this, do

For Ubuntu 16.04

For Ubuntu 18.04

For Ubuntu 20.04

Ubuntu 20.10

Update apt cahe

Install Microsoft ODBC

Optional: for bcp and sqlcmd

Now php MS SQL module will work. You can find sample PHP code at

Here are microsoft documentation


Need help with Linux Server or WordPress? We can help!

One thought on “Install PHP drivers for Microsoft SQL Server on Ubuntu PHP 7.2

Leave a Reply

Your email address will not be published. Required fields are marked *