Php does not recognize PDO_DBLIB driver

So, I am writing code to access SQL Server for Microsft. The code I write is on a Centos 7 machine. I installed the php mysql and mssql packages, but when I run

echo "<pre>", print_r(PDO::getAvailableDrivers()), "</pre>";

I get the following output:

Array
(
   [0] => mysql
   [1] => pgsql
   [2] => sqlite
)

I restarted the lamp and got the same result.

I also edited php.inito turn it on extension=php_mssql.soand restarted the lamp and still got the same result.

When I ran pdo script:

try
{
    $con = new PDO("dblib:host=".$db_addr.";dbname=".$db_name.";charset=utf8", '".$db_usr."', '".$db_pass."');
    $con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e)
{
    echo "ERROR: ". $e->getMessage();
    die(); 
}

I always get:

ERROR: could not find driver

I believe this needs to be configured in php.ini, but the output drivers are commented out from php.ini, so I'm rather confused.

Can someone lead me in the right direction?

EDIT: I followed @ jap1968 answers in here , but I am stuck where I am now.

+4
1

, . xampp. .

, apache (httpd), mysql (MariaDB) php, , @jap1968 .

CentOS MS SQL Server . , script , , , .

, ( root, ):

# setsebool -P httpd_can_network_connect=1
0

All Articles