I just installed a new VM in Azure with Centos 7.2.
On this server I installed httpd using yum install httpd
After that I installed PHP 7.0.7 using the following link: https://webtatic.com/packages/php70/
PHP is working fine with no problem at this point.
But then I want to connect to a Azure SQL Database. After searching the forums of stackoverflow I saw that I need a PHP 7 SQLSRV driver.
I got the driver from this link: https://github.com/Azure/msphpsql/tree/PHP-7.0-Linux/CentOS7
To load the driver I copied the file to the following path: /usr/lib64/php/modules/
And updated the php.ini with the following line extension=/usr/lib64/php/modules/php_sqlsrv_7_ts.so
I did this because I was not sure if the driver is automatically loaded when placed in the modules folder. Does it load automatically?
After that I created a test.php file with the following code.
error_reporting(E_ALL);
ini_set('display_errors', 1);
echo php_ini_loaded_file();
$connectionInfo = array("pwd" => "PASSWORD", $serverName = "tcp:SERVER_URL:1443");
$conn = sqlsrv_connect($serverName, $connectionInfo);
if( $conn ) {
echo "Connection established.<br />"; }
else {
echo "Connection could not be established.<br />";
die( print_r( sqlsrv_errors(), true));
}
The code above gives me the following error:
/etc/php.ini
Fatal error: Uncaught Error: Call to undefined function sqlsrv_connect() in /var/www/website/test.php:9 Stack trace: #0 {main} thrown in /var/www/website/test.php on line 9
Does the PHP SQLSRV driver file needs to be written down in the phpinfo? Because I don't see it there.
Could someone help me out? If you need more information please ask and I will provide it.
Thanks in advance.
UPDATE 1:
When I run php -v
on the server i get the following error:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/php_sqlsrv_7_ts.so' - /usr/lib64/php/modules/php_sqlsrv_7_ts.so: undefined symbol: SQLGetDiagField in Unknown on line 0 PHP 7.0.7 (cli) (built: May 28 2016 07:53:22) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies