0

This was working correctly until my client decided to yum update everything without asking me.

I've installed sqlsrv.so and pdo_sqlsrv.so to /etc/php.d/

PHP -m shows both modules loaded as does command line phpinfo.php

Command line php works great and connects to the MSSQL DB without a problem

Here's the problem

My test script spits out the loaded modules in apache - (sqlsrv not in there) Obviously complains it cannot load the library

----------------------Extensions--------------
Array ( [0] => Core [1] => date [2] => libxml [3] => openssl [4] => pcre [5] => zlib [6] => filter [7] => hash [8] => Reflection [9] => SPL [10] => session [11] => standard [12] => apache2handler [13] => bz2 [14] => calendar [15] => ctype [16] => curl [17] => dom [18] => exif [19] => fileinfo [20] => ftp [21] => gd [22] => gettext [23] => gmp [24] => iconv [25] => json [26] => mysqli [27] => PDO [28] => pdo_mysql [29] => pdo_sqlite [30] => Phar [31] => posix [32] => shmop [33] => SimpleXML [34] => sockets [35] => sqlite3 [36] => sysvmsg [37] => sysvsem [38] => sysvshm [39] => tokenizer [40] => xml [41] => wddx [42] => xmlreader [43] => xmlwriter [44] => xsl [45] => zip [46] => Zend OPcache )
 ----------------------Extensions--------------
Fatal error: Uncaught Error: Call to undefined function sqlsrv_connect() in /var/www/html/db-test.php:26 Stack trace: #0 {main} thrown in /var/www/html/db-test.php on line 26

phpinfo.php (image below) shows the correct /etc/php.ini, but it also scans the thread safe .inis and DOES NOT show sqlsrv.so loaded.

phpinfo.php  from apache

Any idea why is apache not loading my libraries in /etc/php.d/*.so?

alexander.polomodov
  • 1,068
  • 3
  • 10
  • 14
  • Try to check sqlsrv.so and pdo_sqlsrv.so using ldd but probably this library are compiled by other version of gcc (and maybe with different version of library) than actually installed php version with their extensions. You must try to find the newest version of sqlsrv.so and pdo_sqlsrv.so for php v7. I thint this link maybe useful for you to solve your problem: https://github.com/Microsoft/msphpsql/wiki/Install-pdo_sqlsrv-for-PHP-7.0-on-Debian-in-3-ways – mariaczi Jun 27 '18 at 19:39
  • As sum: you must reinstall this extension via pecl (`pecl install sqlsrv` `pecl install pdo_sqlsrv`) or download fresh binaries. – mariaczi Jun 27 '18 at 19:51
  • I did install both with sudo pecl install sqlsrv sudo pecl install pdo_sqlsrv The script works on the command line without a problem - any reason they aren't loading in Apache? I can't find binaries for RHEL - they are the only ones missing :( – Jacob Albert Jun 28 '18 at 00:42
  • Here: https://github.com/Microsoft/msphpsql/releases you can find binaries for CentOS/RedHat released on 23 Mar v5.2 – mariaczi Jun 28 '18 at 06:51
  • Run in terminal `php -i | grep extension` and look for "extension_dir". This is the correct place for extension files. – mariaczi Jun 28 '18 at 06:58
  • I fixed the issue the solution is to add these thread safe libraries php_pdo_sqlsrv_7_ts.so php_sqlsrv_7_ts.so to /usr/lib64/php-zts/modules/ Add sqlsrv.ini, pdo_sqlsrv.ini to /etc/php-zts.d/ – Jacob Albert Jun 29 '18 at 03:54

0 Answers0