PHP 通过 CLI 调用时会加载扩展,但通过 Apache 调用时则不会加载

PHP 通过 CLI 调用时会加载扩展,但通过 Apache 调用时则不会加载

对我来说,只有从 CLI 调用时,PHP 才能完美加载扩展,但通过 Apache 加载页面时则不行。

例如,这是的输出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

但是,通过 Apache 运行时:
1. 在 中phpinfo(),OpenSSL 支持显示为“已禁用”。2
.extension_loaded("curl")false
3.get_loaded_extensions()不包括curlOpenSSL。4
. 尝试使用任何扩展功能都会失败。

这是var_dump(get_loaded_extensions());通过 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"
}

操作系统: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 来自https://www.apachelounge.com/

PHP 和 Apache 通过httpd.conf(mod_php) 进行交互:

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

这台机器上只安装了一个Apache+PHP。


我尝试过的:

  1. 确认 PHP 在两种模式下都使用相同的 ini 文件。如果我从 ini 文件中禁用扩展,它们将停止显示php -m(应该如此)。
  2. (重新)安装 MS Visual Studio C++ Redistributable 2015-19(x86 和 x64)。
  3. 正在重新启动httpd
  4. 正在重新启动电脑。
  5. 重新安装 PHP 和 Apache。
  6. display_startup_errors=on然后检查日志。Apache 和 PHP 错误日志中均没有相关信息。
  7. 确认 PHP 在 的 ZTS 中运行php.exe -v,“线程安全”显示为phpinfo()通过 Apache 启用。

请帮忙。我需要启动并运行这个网络服务器,这让我抓狂不已。

答案1

我通过将 Apache Lounge 二进制文件替换为来自阿帕奇之家

我只是Apache24用新文件夹替换了旧文件夹,但保留了旧conf文件夹。无需进行其他更改。

相关内容