php7 fileinfo,centos php7 安装 fileinfo 失败

centos7 使用 lnmp.org 安装的环境 安装SmartWiki composer install 提示缺少扩展

使用pecl 安装

[root@VM_0_14_centos Fileinfo-1.0.4]# pecl install fileinfo

WARNING: "pear/Fileinfo" is deprecated in favor of "channel://php-src/ext/filein

fo/in php sources"

WARNING: channel "pear.php.net" has updated its protocols, use "pecl channel-upd

ate pear.php.net" to update

downloading Fileinfo-1.0.4.tgz ...

Starting to download Fileinfo-1.0.4.tgz (5,835 bytes)

.....done: 5,835 bytes

3 source files, building

running: phpize

Cannot find config.m4.

Make sure that you run '/usr/local/php/bin/phpize' in the top level source direc

tory of the module

ERROR: `phpize' failed

[root@VM_0_14_centos Fileinfo-1.0.4]#cd /tmp/pear/download/Fileinfo-1.0.4

[root@VM_0_14_centos Fileinfo-1.0.4]# /usr/local/php/bin/phpize

Configuring for:

PHP Api Version: 20160303

Zend Module Api No: 20160303

Zend Extension Api No: 320160303

[root@VM_0_14_centos Fileinfo-1.0.4]# ./configure --with-php-config=/usr/local/

php/bin/php-config

checking for grep that handles long lines and -e... /usr/bin/grep

checking for egrep... /usr/bin/grep -E

checking for a sed that does not truncate output... /usr/bin/sed

checking for cc... cc

checking whether the C compiler works... yes

checking for C compiler default output file name... a.out

checking for suffix of executables...

checking whether we are cross compiling... no

checking for suffix of object files... o

checking whether we are using the GNU C compiler... yes

checking whether cc accepts -g... yes

checking for cc option to accept ISO C89... none needed

checking how to run the C preprocessor... cc -E

checking for icc... no

checking for suncc... no

checking whether cc understands -c and -o together... yes

checking for system library directory... lib

checking if compiler supports -R... no

checking if compiler supports -Wl,-rpath,... yes

checking build system type... x86_64-unknown-linux-gnu

checking host system type... x86_64-unknown-linux-gnu

checking target system type... x86_64-unknown-linux-gnu

checking for PHP prefix... /usr/local/php

checking for PHP includes... -I/usr/local/php/include/php -I/usr/local/php/inclu

de/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend

-I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib

checking for PHP extension directory... /usr/local/php/lib/php/extensions/no-deb

ug-non-zts-20160303

checking for PHP installed headers prefix... /usr/local/php/include/php

checking if debug is enabled... no

checking if zts is enabled... no

checking for re2c... no

configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate

PHP parsers.

checking for gawk... gawk

checking for fileinfo support... yes, shared

checking for magic files in default path... not found

configure: error: Please reinstall the libmagic distribution

wget https://sourceforge.net/projects/re2c/files/0.16/re2c-0.16.tar.gz

tar zxf re2c-0.16.tar.gz && cd re2c-0.16

./configure

make && make install

[root@VM_0_14_centos Fileinfo-1.0.4]# ./configure --with-php-config=/usr/local/

php/bin/php-config 20160303

checking for grep that handles long lines and -e... /usr/bin/grep

checking for egrep... /usr/bin/grep -E

checking for a sed that does not truncate output... /usr/bin/sed

checking for cc... ccFileinfo-1.0.4]#

checking whether the C compiler works... yes

checking for C compiler default output file name... a.out

checking for suffix of executables...

checking whether we are cross compiling... no

checking for suffix of object files... o

checking whether we are using the GNU C compiler... yes

checking whether cc accepts -g... yes

checking for cc option to accept ISO C89... none needed

checking how to run the C preprocessor... cc -E

checking for icc... no

checking for suncc... no

checking whether cc understands -c and -o together... yes

checking for system library directory... lib

checking if compiler supports -R... no

checking if compiler supports -Wl,-rpath,... yes

checking build system type... x86_64-unknown-linux-gnu

checking host system type... x86_64-unknown-linux-gnu

checking target system type... x86_64-unknown-linux-gnu

checking for PHP prefix... /usr/local/php

checking for PHP includes... -I/usr/local/php/include/php -I/usr/local/php/inclu

de/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend

-I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib

checking for PHP extension directory... /usr/local/php/lib/php/extensions/no-deb

ug-non-zts-20160303

checking for PHP installed headers prefix... /usr/local/php/include/php

checking if debug is enabled... no

checking if zts is enabled... no

checking for re2c... re2c

checking for re2c version... 0.16 (ok)

checking for gawk... gawk

checking for fileinfo support... yes, shared

checking for magic files in default path... not found

configure: error: Please reinstall the libmagic distribution

最后 Please reinstall the libmagic distribution 这个错误不知道怎么解决

### 如何在 PHP安装 fileinfo 扩展 为了使 Intervention Image 库正常工作,必须安装并启用 PHPFileinfo 扩展[^1]。以下是针对不同操作系统和环境的具体方法。 #### 对于基于 Debian/Ubuntu 的 Linux 发行版: 可以通过包管理器来轻松安装此扩展。运行以下命令可以完成安装过程: ```bash sudo apt-get update sudo apt-get install php-fileinfo ``` 对于特定版本的 PHP(例如 PHP 7.4),应使用相应的软件包名称: ```bash sudo apt-get install php7.4-fileinfo ``` #### 对于基于 RedHat/CentOS/Fedora 的 Linux 发行版: 同样地,在这些平台上也可以通过 yum 或 dnf 来获取所需的文件信息支持库: ```bash sudo yum install php-pecl-fileinfo # CentOS/RHEL 6, 7 使用yum # 或者 sudo dnf install php-pecl-fileinfo # Fedora 和较新的CentOS/RHEL 版本使用dnf ``` 有时可能会遇到一些问题,比如找不到合适的仓库或者依赖关系无法解决等问题,则可能需要手动编译安装该模块[^3]。 #### Windows 平台上的操作指南: Windows 用户通常只需要编辑 `php.ini` 文件并将下面这行前面的分号去掉即可激活内置的支持: ```ini ;extension=php_fileinfo.dll ``` 修改完成后重启 Web 服务器服务让更改生效。 #### macOS 上的操作方式: Homebrew 是 Mac OS X 下非常流行的开源工具集,它可以帮助简化开发人员的工作流程。要在此类环境中添加对 FileInfo API 的访问权限,请执行下列指令: ```bash brew reinstall php --with-php-config ``` 注意:以上命令假设已经正确设置了 Homebrew 及其关联的 PHP 软件包;如果不是这种情况,请先按照官方文档说明进行必要的初始化设置。 #### OneinStack 环境下的特殊处理: 当在一个由 OneinStack 构建的服务集群里部署应用程序时,除了上述常规手段外还需要额外关注某些细节配置项。特别是涉及到多版本 PHP 共存的情况下更应该小心谨慎对待每一个环节[^2]。 #### 验证安装成功与否: 无论采用哪种途径来进行这项工作的实施之后都建议立即验证新功能是否可用。最简单的方法就是创建一个新的 PHP 测试页面包含如下代码片段: ```php <?php echo function_exists('finfo_open') ? 'Fileinfo enabled' : 'Fileinfo not available'; ?> ``` 如果浏览器返回字符串 "Fileinfo enabled" 则表示一切顺利!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值