0
votes

I can't use any php extension. PHP works without unccommented extensions. Text from error.log:

PHP Warning: PHP Startup: Unable to load dynamic library 'd:/work/www/php/ext/{any_extension}.dll'

I have Windows 10 x64, PHP7 x64, Apache 2.4 x64;

Extensions line in php.ini:

extension_dir = "d:/work/www/php/ext/"

Path is correct

I added this in the Windows PATH:

d:/work/www/php
d:/work/www/php/ext
d:/work/www/apache
d:/work/www/apache/bin

Text from phpinfo:

extension_dir - d:/work/www/php/ext

Syntax like

extension=D:/work/www/php/ext/{any_extension}.dll

in php.ini doesn't change anything.

Can anyone tell me what's wrong?

1
I think you must replace / with \ in your path. extension_dir = "d:\work\www\php\ext\"Saeed M.
Forward slashes are fine. You have verified that the directory exists and the extensions you're trying to load are actually there?Markus AO
smoqadam, nope, you can write / or \, it doesn't change anything. And yes, I tried.WeekendMan
Markus AO, of course, it all exists.WeekendMan

1 Answers

2
votes

Make sure that:

  • extensions in your php.ini are noted as extension=curl, extension=ldap, etc.
    PHP 7+ config uses this format instead of extension=php_curl.dll in previous versions (which is still supported for legacy reasons, but is deprecated).
  • config line extension_dir = "C:/path_to_your_php/" contains absolute path to your php extensions dir.
  • proper Visual C++ Redist's are installed in your system. E.g. PHP 7 x64 and Apache 2.4 x64 both require VCRedist 2017 (x64: https://aka.ms/vs/15/release/vc_redist.x64.exe, x86: https://aka.ms/vs/15/release/vc_redist.x86.exe)
  • add config lines below to your <apache_dir>/conf/httpd.conf file:
Loadfile "path_to_php_dir/libsasl.dll"
LoadFile "path_to_php_dir/libpq.dll"
LoadFile "path_to_php_dir/php7ts.dll"
LoadFile "path_to_php_dir/libssh2.dll"
LoadFile "path_to_php_dir/nghttp2.dll"
LoadFile "path_to_php_dir/libcrypto-1_1-x64.dll"
LoadFile "path_to_php_dir/libssl-1_1-x64.dll"

This makes Apache to preload these files so your extensions wouldn't fail on load. You can add any other DLL from your /php directory if some extensions need it.

  • other extensions DLLs and/or PHP DLLs dependencies are not missed. You can use free "Dependency Walker" tool (http://www.dependencywalker.com/) to inspect each of DLL files loading for missed dependencies (php_dir/php*.dll, php_dir/ext/*.dll, ...).