logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

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

or

Bitcoin

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
Author
VEG



Joined: 20 Dec 2020
Posts: 4
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
Code:
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:

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

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


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/webdev/apache_adddlldirectory.7z (3.5KB, source code included).


Last edited by VEG on Tue 18 May '21 17:20; edited 3 times in total
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
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
VEG



Joined: 20 Dec 2020
Posts: 4
Location: Belarus

PostPosted: Sun 25 Apr '21 15:05    Post subject: Reply with quote

PHP developers can't resolve this issue from their php8apache2_4.dll, just because the php8apache2_4.dll basically can't be loaded without such fix. If Apache tells windows to look for dependencies in the module's directory before trying to load the module, the issue is resolved.
Back to top
VEG



Joined: 20 Dec 2020
Posts: 4
Location: Belarus

PostPosted: Wed 03 Nov '21 15:20    Post subject: Reply with quote

Oh, seems like I was wrong, and actually the issue is related to loading PHP extensions, and better to be fixed from the PHP module side. Will try to discuss it with PHP developers.
Back to top
James Blond
Moderator


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

PostPosted: Thu 04 Nov '21 0:20    Post subject: Reply with quote

For any php extensions issues. Run php -m to see what fails, and set display start up errors in php.ini

IS there a reason you don't run php via mod_fcgid?
Back to top
Otomatic



Joined: 01 Sep 2011
Posts: 213
Location: Paris, France, EU

PostPosted: Thu 04 Nov '21 10:51    Post subject: Reply with quote

Hi,

There is no problem with full path
Code:

Define VERSION_APACHE 2.4.51
Define INSTALL_DIR E:/wamp64
Define APACHE_DIR ${INSTALL_DIR}/bin/apache/apache${VERSION_APACHE}
Define SRVROOT ${INSTALL_DIR}/bin/apache/apache${VERSION_APACHE}
...
PHPIniDir "${APACHE_DIR}/bin"
LoadModule php_module "${INSTALL_DIR}/bin/php/php8.0.12/php8apache2_4.dll"
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