Jack
Jack

Reputation: 29

Microsoft SQL PHP extensions won't load on Apache startup

I'm running Apache24 on a Windows Server 2016 64bit and PHP 7.4.1 I've been trying to get the Microsoft dlls to load on Apache startup, but have failed to find a solution. As I understand it, all that is required is to copy the .dlls to the PHP ext directory, and add the extensions to PHP.ini.

I did read the similar posts on PHP extensions not loading. I have checked that the ext directory (e:\php74\ext) is correct in the PHP.ini file and that the files do exist in that directory, but I get these errors on starting Apache24:

PHP Warning:  PHP Startup: Failed to load e:\\php74\\ext\\php_sqlsrv_74_ts_x64, The system cannot find the file specified.\r\n in Unknown on line 0
PHP Warning:  PHP Startup: Failed to load e:\\php74\\ext\\php_pdo_sqlsrv_74_ts_x64, The system cannot find the file specified.\r\n in Unknown on line 0

I don't understand where the double slashes are coming from, here is a snippet of the php.ini file:

; added extension for Microsoft SQL server
extension=e:\php74\ext\php_sqlsrv_74_ts_x64
extension=e:\php74\ext\php_pdo_sqlsrv_74_ts_x64

I've been at this for days. Guidance on what I am missing would be greatly appreciated.

Upvotes: 1

Views: 301

Answers (1)

Jack
Jack

Reputation: 29

After a lot of experimenting, using suggestions from other posts, I did manage to get the 2 extensions loaded. What I did was:

  1. In the php.ini (around line 760) I defined the path to the default php ext folder and encapsulated it in quotes: "E:\php74\ext" Note the final .
  2. I added the 2 extension references (around line 900 in php.ini) in this order: extension=php_pdo_sqlsrv_74_ts_x64.dll extension=php_sqlsrv_74_ts_x64.dll Note The order is required, No "'s and the inclusion of .dll Once I rebooted Apache, phpinfo() showed both drivers loaded.

Upvotes: 0

Related Questions