0

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?

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

2 Answers 2

2

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, ...).
Sign up to request clarification or add additional context in comments.

Comments

0

In my Apache configuration "C:\Apache24\conf\httpd.conf"

PHPIniDir "C:\Apache24\php-7.4.29" → fail
PHPIniDir "C:\Apache24\php-7.4.29\" → ok - notice the backslash at the end !


# extract of httpd.conf
LoadModule php7_module "C:\Apache24\php-7.4.29\php7apache2_4.dll"
PHPIniDir "C:\Apache24\php-7.4.29\"
AddType application/x-httpd-php .php 

# extract of php.ini
extension_dir = "C:\Apache24\php-7.4.29\ext\"

...
extension=fileinfo
extension=gd2
...

1 Comment

Do not add the same answer, vote to close instead

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.