[英]Apache isn't loading PHP extensions
I installed(manually) Apache and PHP.我安装(手动)Apache 和 PHP。 I activated the curl extension from php.ini and It's working fine in PHP-CLI, but when I access PHP through browser with the help of Apache, curl(and any other) extension giving me errors that "{extension_function} is undefined"
我从 php.ini 激活了 curl 扩展,它在 PHP-CLI 中运行良好,但是当我在 Apache 的帮助下通过浏览器访问 PHP 时,curl(和任何其他)扩展给了我“{extension_function} 未定义”的错误
PHP 7.2-64bit
PHP
7.2-64bit
Apache 2.4
阿帕奇
2.4
// php.ini
extension_dir = "/server/php/ext"
...
extension=bz2
extension=curl
extension=fileinfo
;extension=gd2
;extension=gettext
;extension=gmp
;extension=intl
;extension=imap
;extension=interbase
;extension=ldap
;extension=mbstring
;extension=exif ; Must be after mbstring as it depends on it
extension=mysqli
;extension=oci8_12c ; Use with Oracle Database 12c Instant Client
;extension=odbc
extension=openssl
;extension=pdo_firebird
extension=pdo_mysql
;extension=pdo_oci
;extension=pdo_odbc
;extension=pdo_pgsql
;extension=pdo_sqlite
;extension=pgsql
;extension=shmop
// httpd.conf
LoadModule php7_module "/server/php/php7apache2_4.dll"
<IfModule php7_module>
AddHandler application/x-httpd-php .php
AddType application/x-httpd-php .php .html
PHPIniDir "/server/php"
</IfModule>
Update更新
I'm testing using this var_dump(function_exists('curl_init'));
我正在测试使用这个
var_dump(function_exists('curl_init'));
line of code ... when I run this line from php-cli, It's returning true.代码行...当我从 php-cli 运行这一行时,它返回 true。 When I run this line from a php file using browser, It's returning false.
当我使用浏览器从 php 文件运行这一行时,它返回 false。
Solved解决了
- I used absolute paths everywhere(no relative path)(used forward slashes)
我到处都使用绝对路径(没有相对路径)(使用正斜杠)
- Added PHP to environment variables.
将 PHP 添加到环境变量中。 I don't know why, but without this extensions aren't loading.
我不知道为什么,但没有这个扩展就无法加载。 I think php7 module for Apache requires php in environment.
我认为 Apache 的 php7 模块在环境中需要 php。
- Restarted the computer(Apache restart won't work)
重新启动计算机(Apache 重新启动不起作用)
I hope someone will find this helpful.我希望有人会发现这很有帮助。
Thank you for the help.感谢您的帮助。
I had the same problem - on Windows.我有同样的问题 - 在 Windows 上。 After changing the path to the extension directory to an absolute path, it worked.
将扩展目录的路径更改为绝对路径后,它起作用了。
As suggested in the default php.ini (not working):正如默认的 php.ini 中所建议的(不工作):
extension_dir = "ext"
Turned into an absolute path (working)变成绝对路径(工作)
extension_dir = "c:\amp\php\ext"
The strange thing is that this problem occurs on some machines / versions only.奇怪的是,这个问题只出现在某些机器/版本上。 Could not nail it down.
无法确定。 There is an official bug listed here:
这里列出了一个官方错误:
https://bugs.php.net/bug.php?id=74866 https://bugs.php.net/bug.php?id=74866
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.