微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Apache 2.4,PHP 7.4.7,Windows 10无法从Apache Service加载cURL Extension,但可以从带有httpd的命令行中很好地加载

如何解决Apache 2.4,PHP 7.4.7,Windows 10无法从Apache Service加载cURL Extension,但可以从带有httpd的命令行中很好地加载

我已经为这个问题解决了2天,但似乎无法解决。 我在计算机上安装了Apache,并以localhost身份运行。我没有SSL,但是尝试了是否加载openssl扩展。 如果我从“ Windows服务”启动Apache 24服务,PHP可以运行,但不会加载任何扩展dll,特别是我正在尝试加载cURL。如果我停止“ Windows服务”并在命令提示符下运行httpd,则所有扩展都将正常加载。

有趣的是,除了从“ Windows服务”运行时的扩展之外,所有PHP功能都可以正常工作。

当我第一次启动“ Apache Windows Service”时,事件日志显示以下内容

PHP[29280] 
PHP Warning: PHP Startup: Unable to load dynamic library 'php_curl' (tried: ext\php_curl (The specified module Could not be found.),ext\PHP_php_curl.dll (The specified module Could not be found.)) (D:\Apache24\bin\httpd.exe -d D:/Apache24) 

我在PHPinfo中找到的唯一真实线索是我看到的“ Windows Service”和命令行httpd之间的区别是:

“ Windows服务”

enter image description here

“命令行httpd”

enter image description here

我的PHP.ini文件对cURL具有以下设置:

extension_dir = "ext"
extension=curl
extension=openssl

PHP信息屏幕截图:

两者共同

enter image description here

使用命令行“ httpd”

enter image description here

使用Windows服务(请注意,缺少cURL,事件日志显示上述错误

enter image description here

我还注意到“配置文件PHP.ini)路径”设置为“ C:\ Windows”,因此我尝试将PHP.ini文件复制到c:\ windows并复制了包含所有dll的ext文件夹到C:\ Windows,但仍然有完全相同的问题。此后,我从C:\ Windows中删除PHP.ini和ext文件夹,以避免将来出现任何路径问题。

有人知道我想念什么吗?

解决方法

将扩展目录的路径定义为的完整路径

extension_dir = "ext"

extension_dir = "c:\PHP7.4.7\ext"

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。