宝塔面板PHP安装不上fileinfo扩展?

开通会员

前言

宝塔面板问题解决 – PHP安装不上fileinfo扩展?

不知道大家在使用宝塔面板的时候,为PHP安装fileinfo扩展感到非常苦恼?
我前两天为我的PHP7.4安装fileinfo扩展时,怎么安装都安装不上,然后在网上找各种此问题的解决方案,但是都没有解决我的这个问题。

最后实在找不到此问题的解决方案了,干脆靠自己吧。分析分析扩展安装时的日志看看问题到底出错在哪里。因为我的服务器是4核4G的,首先排除因内存小的原因导致安装不上。

以下是扩展安装时的日志:

Connecting to na1-node.bt.cn (na1-node.bt.cn)|128.1.164.196|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5435 (5.3K) [application/octet-stream]
Saving to: ‘fileinfo.sh’

0K ..... 100% 213M=0s

2023-07-06 11:13:40 (213 MB/s) - ‘fileinfo.sh’ saved [5435/5435]

正在选择下载节点...
Configuring for:
PHP Api Version: 20190902
Zend Module Api No: 20190902
Zend Extension Api No: 320190902
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for pkg-config... /bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
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 for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for PHP prefix... /www/server/php/74
checking for PHP includes... -I/www/server/php/74/include/php -I/www/server/php/74/include/php/main -I/www/server/php/74/include/php/TSRM -I/www/server/php/74/include/php/Zend -I/www/server/php/74/include/php/ext -I/www/server/php/74/include/php/ext/date/lib
checking for PHP extension directory... /www/server/php/74/lib/php/extensions/no-debug-non-zts-20190902
checking for PHP installed headers prefix... /www/server/php/74/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for gawk... gawk
checking for fileinfo support... yes, shared
checking for strcasestr... yes
checking for utimes... yes
checking for strndup... yes
checking for a sed that does not truncate output... /bin/sed
checking for ld used by cc... /bin/ld
checking if the linker (/bin/ld) is GNU ld... yes
checking for /bin/ld option to reload object files... -r
checking for BSD-compatible nm... /bin/nm -B
checking whether ln -s works... yes
checking how to recognize dependent libraries... pass_all
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking the maximum length of command line arguments... 1572864
checking command to parse /bin/nm -B output from cc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC
checking if cc PIC flag -fPIC works... yes
checking if cc static flag -static works... no
checking if cc supports -c -o file.o... yes
checking whether the cc linker (/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no

creating libtool
appending configuration tag "CXX" to libtool
configure: patching config.h.in
configure: creating ./config.status
config.status: creating config.h
config.status: config.h is unchanged
/bin/sh /www/server/php/74/src/ext/fileinfo/libtool --mode=link cc -DPHP_ATOM_INC -I/www/server/php/74/src/ext/fileinfo/include -I/www/server/php/74/src/ext/fileinfo/main -I/www/server/php/74/src/ext/fileinfo -I/www/server/php/74/include/php -I/www/server/php/74/include/php/main -I/www/server/php/74/include/php/TSRM -I/www/server/php/74/include/php/Zend -I/www/server/php/74/include/php/ext -I/www/server/php/74/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -o fileinfo.la -export-dynamic -avoid-version -prefer-pic -module -rpath /www/server/php/74/src/ext/fileinfo/modules fileinfo.lo libmagic/apprentice.lo libmagic/apptype.lo libmagic/ascmagic.lo libmagic/cdf.lo libmagic/cdf_time.lo libmagic/compress.lo libmagic/encoding.lo libmagic/fsmagic.lo libmagic/funcs.lo libmagic/is_json.lo libmagic/is_tar.lo libmagic/magic.lo libmagic/print.lo libmagic/readcdf.lo libmagic/softmagic.lo libmagic/der.lo libmagic/buffer.lo
libtool: link: `libmagic/buffer.lo' is not a valid libtool object
make: *** [Makefile:231: fileinfo.la] Error 1
error
|-Successify --- 命令已执行! ---

可以看到问题出现在

libtool: link: `libmagic/buffer.lo' is not a valid libtool object

这可能是因为编译过程中的某个文件损坏或错误引起的。

我们既然找到了问题错误的所在,那么我们就直接看看怎么去解决这个问题吧!

问题解决

第一步:

首先让我们确保系统已安装正确的编译工具和依赖项。运行以下命令来安装所需的软件包:

sudo yum install gcc libtool autoconf

注意:我的是CentOS Stream 8 x86_64(Py3.7.9)系统的,使用的是Linux面板,其他面板并没有测试过,如果你也是出现无法安装fileinfo扩展的话并且不是Linux面板,请自行更换命令行。

第二步:

清理之前的构建文件。运行以下命令来清理可能存在的残留文件:

cd /www/server/php/74/src/ext/fileinfo
make clean

第三步:

重新配置并编译 fileinfo 扩展。运行以下命令来重新配置和编译:

cd /www/server/php/74/src/ext/fileinfo
/www/server/php/74/bin/phpize
./configure --with-php-config=/www/server/php/74/bin/php-config
make

如果上述命令执行成功,您应该会看到类似以下内容的输出:

Build complete.
Don't forget to run 'make test'.

第四步:

安装编译后的扩展。运行以下命令来安装扩展:

make install

第五步:

在 PHP 配置文件中启用 fileinfo 扩展。打开 PHP 配置文件(通常位于 /www/server/php/74/etc/php.ini)在该配置文件最后写上以下内容:

extension=fileinfo

第六步:

重新启动 Web 服务器。运行以下命令来重新启动服务器以使更改生效:

sudo systemctl restart nginx

无法安装fileinfo扩展到这里就已经可以解决了,如果问题仍然存在,您可能需要检查其他错误日志或尝试使用其他方法或工具来安装 fileinfo 扩展。

注意事项

© 版权声明
THE END
喜欢就支持一下吧
点赞11 分享