1

PHP for me only loads exensions perfectly when called from the CLI, but not when I load pages through Apache.

For example, this is the output of php -m:

[PHP Modules]
bcmath
calendar
Core
ctype
curl
date
dom
filter
hash
iconv
json
libxml
mysqlnd
openssl
pcre
PDO
Phar
readline
Reflection
session
SimpleXML
SPL
standard
tokenizer
xml
xmlreader
xmlwriter
zip
zlib

However, when run through Apache:
1. In phpinfo(), OpenSSL support shows up as "disabled".
2. extension_loaded("curl") is false
3. get_loaded_extensions() doesn't include curl or OpenSSL.
4. Trying to use any of the extensions's functions fails.

Here's var_dump(get_loaded_extensions()); when running through Apache:

array(28) {
  [0]=>
  string(4) "Core"
  [1]=>
  string(6) "bcmath"
  [2]=>
  string(8) "calendar"
  [3]=>
  string(5) "ctype"
  [4]=>
  string(4) "date"
  [5]=>
  string(6) "filter"
  [6]=>
  string(4) "hash"
  [7]=>
  string(5) "iconv"
  [8]=>
  string(4) "json"
  [9]=>
  string(3) "SPL"
  [10]=>
  string(4) "pcre"
  [11]=>
  string(8) "readline"
  [12]=>
  string(10) "Reflection"
  [13]=>
  string(7) "session"
  [14]=>
  string(8) "standard"
  [15]=>
  string(7) "mysqlnd"
  [16]=>
  string(9) "tokenizer"
  [17]=>
  string(3) "zip"
  [18]=>
  string(4) "zlib"
  [19]=>
  string(6) "libxml"
  [20]=>
  string(3) "dom"
  [21]=>
  string(3) "PDO"
  [22]=>
  string(4) "Phar"
  [23]=>
  string(9) "SimpleXML"
  [24]=>
  string(3) "xml"
  [25]=>
  string(9) "xmlreader"
  [26]=>
  string(9) "xmlwriter"
  [27]=>
  string(14) "apache2handler"
}

OS: Windows 10 1809, up to date.

php -v:

PHP 7.4.5 (cli) (built: Apr 14 2020 16:17:34) ( ZTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

httpd: Apache 2.4.43 Win64 from https://www.apachelounge.com/

PHP and Apache interacting through this in httpd.conf (mod_php):

LoadModule php7_module "C:/<path_to_PHP>/PHP7/php7apache2_4.dll"

There is only one Apache+PHP install on this machine.


What I've tried:

  1. Confirmed that PHP is using the same ini file in both modes. If I disable extensions from the ini file, they stop showing in php -m (as they should).
  2. (Re)installing MS Visual Studio C++ Redistributable 2015-19 (both x86 and x64).
  3. Restarting httpd.
  4. Restarting PC.
  5. Reinstalling PHP and Apache.
  6. display_startup_errors=on and then checking logs. There is no relevant info in both Apache and PHP error logs.
  7. Confirmed PHP is running in ZTS in php.exe -v, "Thread Safety" shows up as enabled in phpinfo() through Apache.

Please help. I need this webserver up and running, and this is driving me crazy.

undo
  • 131
  • 8
  • Would you mind adding the loadfile and loadmodule directives concerning openssl and curl to your question? – Gerard H. Pille May 05 '20 at 20:35
  • @GerardH.Pille I'm not sure what you're talking about? PHP extensions are loaded by adding (or uncommenting) them in `php.ini`. – undo May 05 '20 at 21:06
  • Got it from https://www.apachelounge.com/viewtopic.php?t=1641. Also, you could avoid your problem with fcgi https://www.apachelounge.com/viewtopic.php?p=39070 – Gerard H. Pille May 06 '20 at 00:44
  • "using the same ini file", but there may be more than one. Check phpinfo for "Additional .ini files parsed" and compare them. – Gerard H. Pille May 05 '20 at 19:22

1 Answers1

1

I was able to solve the issue by replacing the Apache Lounge binaries with ones from Apache Haus.

I just replaced the old Apache24 folder with the new one, but retained the old conf folder. No other changes needed to be made.

undo
  • 131
  • 8