自定义 PHP 构建中的 PHP Fileinfo - Linux

自定义 PHP 构建中的 PHP Fileinfo - Linux

由于一些历史原因,我们定制了 PHP 安装,并将其安装到我们自定义的 Apache 编译中。

我们现在正尝试将 Fileinfo 加载到 PHP 构建中,并尝试了常用的 Pecl 安装 fileinfo 并在 php.ini 中启用它,但没有效果。

更奇怪的是,phpinfo() 输出中的 fileinfo 根本没有列出任何版本。尝试运行基本 finfo 函数时出现以下错误

Fatal error: Class 'finfo' not found

系统是 Debian Linux。PHP 是 5.2.10。我们无法迁移到 5.3.0,因为 Joomla 无法与它兼容。

如果有人能告诉我们导致这种情况的原因,我们将非常感激。

答案1

您的 php.ini extension_dir 设置为何?

在我们的例子中,pecl 将扩展安装到 /usr/local/lib/php/ext/no-debug-non-zts-20060613,但 extension_dir ini 设置为“./”或“/usr/local/lib/php/ext”。pecl install 的输出应该会告诉您扩展的安装位置,因此您只需更改 extension_dir 以匹配或将 fileinfo.so 文件移动到 php.ini 中指定的目录即可。

答案2

我以前也遇到过同样的问题。首先加载 fileinfo 扩展名(应该显示在 phpinfo() 中)。然后检查 /usr/share 中是否有一个名为“magic”的符号链接。如果没有,只需创建一个指向 file/magic 的链接。

答案3

我们设法通过删除 magic_mime 然后将 fileinfo 直接编译到 php 安装中来解决这个问题。

remove magic_mime from the ext directory inside of the php source
grab Fileinfo source and put inside of the ext directory
run autoconf in the root php source directory
configure and compile normally

相关内容