CentOS: MS SQL driver installed and configured, yet not available to PHP

centosPHPsql server

On a CentOS 7.3 machine running PHP 5.6 I have installed and configured the MS SQL driver for PDO, yet it is not available to PHP.

See that the driver is properly installed and configured:

$ yum list php56w-mssql
Installed Packages
php56w-mssql.x86_64            5.6.30-1.w7        @webtatic

$ cat /etc/php.d/mssql.ini
; Enable mssql extension module
extension=mssql.so

However, PHP doesn't recognize it:

$ php -i | grep 'PDO drivers'
PDO drivers => dblib, mysql, sqlite

How might I troubleshoot this?

Best Answer

Unfortunately I was unable to get the MS SQL extension to work properly. However, PHP can connect to MS SQL via ODBC:

$ yum list php56w-odbc
Installed Packages
php56w-odbc.x86_64    5.6.30-1.w7    @webtatic

$ cat /etc/php.d/odbc.ini 
extension=odbc.so

And then in PHP:

$mssqldriver = 'ODBC Driver 13 for SQL Server';
$hostname='1.2.3.4';
$dbname='foobar';
$username='';
$password='';

$dsn = "odbc:Driver={$mssqldriver};Server={$hostname};Database={$dbname};MARS_Connection=yes";
$pdo= new PDO($dsn, $username, $password);

Be sure to specify MARS Connection, otherwise the connection will be limited on only a single pending request.