0

Im tring to install php 7.1.13 on apache but i keep getting errors when i try to restart/start the apache,

The request operation has failed!

And in my logs i keep getting the error that the php extensions could not be found.But thats not possible because i use absolute path to my /ext folder.

 PHP Warning:  PHP Startup: Unable to load dynamic library
 'D:\\apache\\php7\\ext\\php_mbstring.dll'

I also have older PHP7 folder and that one works fine but as soon i want to upgrade to a higher version i keep getting these errors.

2 Answers2

0

The reason might be that your php executable and extension library were compiled by different versions of compilers. Read here how to find out which compilers were used in both files: Is there a way to determine which version of Visual Studio was used to compile a static library?

Jacek Dziurdzikowski
  • 2,015
  • 2
  • 13
  • 20
  • @MartinRogu The only idea comes to my mind is that you should have both compiled with the same compiler, there are available packages like xampp for Windows which contains matching files, you can also compile code of both by yourself I guess, but also I guess you are able to download compiled files with specified version of compiler for windows. But first you should check if that is the case in fact. – Jacek Dziurdzikowski Jan 31 '18 at 19:37
0

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 config block makes Apache to preload these files, so your extensions wouldn't fail on load due to mismatched dependencies.

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

    As I understood, the problem is that PHP extensions need some dynamic libraries to be loaded (so called "library dependencies"). If they were not, you're getting error "Unable to load dynamic library ..... Unknown in line 0". Many times I was getting this error, the problem was in mismatched DLL dependencies.
KrenUser
  • 21
  • 4