php的fileinfo拓展


安装alipay的电脑网站支付php库,使用composer安装居然提示需要fileinfo拓展,买了个表马云你哪里来的底气!

[root@goodhost com.www]# composer require alipaysdk/easysdk:^2.0
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Continue as root/super user [yes]? 
./composer.json has been updated
Running composer update alipaysdk/easysdk
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - alipaysdk/easysdk[2.0.0, ..., 2.0.3] require ext-fileinfo * -> it is missing from your system. Install or enable PHP's fileinfo extension.
    - Root composer.json requires alipaysdk/easysdk ^2.0 -> satisfiable by alipaysdk/easysdk[2.0.0, 2.0.1, 2.0.2, 2.0.3].

To enable extensions, verify that they are enabled in your .ini files:
    - /usr/local/php/etc/php.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

这么一个小小的库居然要我加拓展,真够逗逼!!!

搜索的确没有安装 php -m|grep fileinfo,没办法,人在屋檐下不得不低头。

网络很多需要去php官网下载拓展的gz包,其实如果你当初的编译前文件夹没有删除,直接用也是妥妥的。

去下载的就别搞了,谁叫你偷懒不是自己编译的呢?自行百度吧。

还好我没删除,这里说的是/root/php-7.4.10/ext/文件夹下的操作。

详细步骤

先开启一下fileinfo拓展

打开vim /usr/local/php/etc/php.ini,找到extension=fileinfo把前面的分号去掉,备用。

使用phpize安装拓展

进入拓展目录:cd /root/php-7.4.10/ext/fileinfo

执行一下:/usr/bin/phpize

找到php-config文件所在:find / -name php-config

执行编译配置: ./configure --with-php-config=/usr/local/php/bin/php-config

执行编译安装:make && make install

提示如下表示成功了:

/bin/sh /root/php-7.4.10/ext/fileinfo/libtool --mode=install cp ./fileinfo.la /root/php-7.4.10/ext/fileinfo/modules
libtool: install: cp ./.libs/fileinfo.so /root/php-7.4.10/ext/fileinfo/modules/fileinfo.so
libtool: install: cp ./.libs/fileinfo.lai /root/php-7.4.10/ext/fileinfo/modules/fileinfo.la
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/sbin" ldconfig -n /root/php-7.4.10/ext/fileinfo/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /root/php-7.4.10/ext/fileinfo/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the 'LD_RUN_PATH' environment variable
     during linking
   - use the '-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to '/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

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

Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-zts-20190902/

重启一下php-fpm

service php-fpm restart

检查拓展加载情况:php -m|grep fileinfo


原文链接:https://blog.yongit.com/note/855265.html