3

For some reason, my php extensions are enabled, but not loaded by my Apache 2.4 server. The extensions I am missing are mbstring and fileinfo. I did the installation manually and I wish to keep it that way, mostly for learning purposes.

When I say enabled, I mean that when I run php -m in cmd, the extensions are in the list

However, when I run <?php phpinfo(); from my server, these extensions are not in the list.

In my php.ini file, I have only configured the follwing (related to extensions):

extension_dir = "ext"
extension=mbstring (uncommented the line)
extension=fileinfo (uncommented the line)

I added the following to httpd.conf:

# PHP5 module
LoadModule php7_module "C:/php/php7apache2_4.dll"
AddType application/x-httpd-php .php
PHPIniDir "C:/php/"

And, in phpinfo(), I see only a single php.ini is loaded, the one from C:/php

Why would my extensions not be available on my Apache server? Do I have to load/enable them manually in Apache somehow?

*Versions: Apache 2.4.39, PHP 7.3.4

DCardinal
  • 31
  • 1
  • 3
  • Not sure about a source install, but most distributions use a different ini file path for cli php vs. sapi interface (webserver) – ivanivan Apr 21 '19 at 05:05
  • @ivanivan I'm not sure if this answers your comment, by from phpinfo I see only single a php.ini loaded, and it's the one from C:/php – DCardinal Apr 22 '19 at 03:59
  • Did you restart Apache? If you are using PHP with Apache, you need to restart Apache for the changes to take effect. – Giacomo1968 Jan 26 '23 at 02:23

1 Answers1

0

I am having the same problem with my own extensions outside of the normal Apache PHP type of configuration. What I found is if I don't use Apache as a service and I open a command console to start Apache, it will load. It's the only way it will load. Don't use a batch process or the service.

For Windows,

  1. press Winkey+R,
  2. type cmd,
  3. press Ctrl+Shift+Enter, and
  4. click "yes".
  5. Then, cd to your Apache/bin directory and type httpd.

I think if you do anything outside the norm, custom extensions won't work unless you build your own executables.

  • One final note my custom extension references another dll that has to be in the httpd bin directory in order to fully function. – developer68 Nov 11 '19 at 14:49
  • Was just looking at my old replies and realized that this one has an additional item. Apache needs to be started based on the user since a user account is associated with certain file privileges. The system account and the user account are not the same thing. – developer68 Jun 28 '22 at 18:24