Apache Lounge


About Forum Index Downloads Search Register Log in  RSS Apache Lounge  

Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.



A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.

Post new topic   Forum Index -> Third-party Modules View previous topic :: View next topic
Reply to topic   Topic: Resolution of the 'Unable to initialize module' PHP error

Joined: 20 Dec 2020
Posts: 2
Location: Belarus

PostPosted: Sun 20 Dec '20 17:24    Post subject: Resolution of the 'Unable to initialize module' PHP error Reply with quote

Robust resolution of the "Unable to initialize module" PHP startup error when Windows can't find libraries which are required for the PHP module. Can be useful for other external Apache modules also.

Apache should call AddDllDirectory for directory of a PHP module before loading the module. Apache could make it automatically as a part of the
LoadModule php_module "${PHPROOT}/php8apache2_4.dll"
instruction, or we could introduce a new Apache configuration instruction "AddDllDirectory" for this purpose, and a developer could put this instruction into httpd.conf explicitly when required before loading of the module. What do you think about this? Could we improve the Windows builds of the Apache available from the apachelounge.com this way?

This function is available since Windows Vista. Modern builds of the Apache also don't support Windows XP. So, it won't reduce compatibility.

I can create a patch with this feature for the Apache if the maintainers are interested.

As a temporary workaround, long time ago I created a library for this purpose which can be loaded from the httpd.conf using standard LoadFile instruction like this:

Define PHPROOT "${SRVROOT}/php8"
LoadFile "${PHPROOT}/AddDllDirectory64.dll"
LoadModule php_module "${PHPROOT}/php8apache2_4.dll"

<FilesMatch \.php$>
    SetHandler application/x-httpd-php

The AddDllDirectory64.dll adds the directory where it is placed to list of directories where Windows will look for dll files for current process. Works flawlessly.

Download: https://veg.by/files/winsoft/apache_adddlldirectory.7z (3.5KB, source code included).
Back to top
James Blond

Joined: 19 Jan 2006
Posts: 6921
Location: Germany, Next to Hamburg

PostPosted: Tue 09 Feb '21 20:53    Post subject: Reply with quote

php8apache2_4 is part of PHP, not Apache. Did you sent your patch to the PHP devs?
Back to top

Reply to topic   Topic: Resolution of the 'Unable to initialize module' PHP error View previous topic :: View next topic
Post new topic   Forum Index -> Third-party Modules