Call to undefined function think\finfo_open()

  1. linux服务器环境搭建的时候,fileinfo扩展从php5.3之后默认是开启的,可能是为了方便没有编译安装;
  2. 首先找到fileinfo目录;
    [root@izm5eb1zq3z60zvnqzti7yz ~]# find / -name fileinfo
    /usr/local/php/ext/fileinfo
    

     

  3.  进入此目录,执行 /usr/local/php/bin/phpize 会产生 configure文件
    [root@izm5eb1zq3z60zvnqzti7yz bin]# cd /usr/local/php/ext/fileinfo
    [root@izm5eb1zq3z60zvnqzti7yz fileinfo]# ls
    config.m4   create_data_file.php  data_file.c   fileinfo.c    libmagic        magicdata.patch  package.xml     tests
    config.w32  CREDITS               EXPERIMENTAL  fileinfo.php  libmagic.patch  Makefile.frag    php_fileinfo.h
    [root@izm5eb1zq3z60zvnqzti7yz fileinfo]# /usr/local/php/bin/phpize
    Configuring for:
    PHP Api Version:         20170718
    Zend Module Api No:      20170718
    Zend Extension Api No:   320170718
    [root@izm5eb1zq3z60zvnqzti7yz fileinfo]# ls
    acinclude.m4    config.h.in   config.w32            fileinfo.c      ltmain.sh        mkinstalldirs
    aclocal.m4      config.m4     create_data_file.php  fileinfo.php    magicdata.patch  package.xml
    autom4te.cache  config.sub    CREDITS               install-sh      Makefile.frag    php_fileinfo.h
    build           configure     data_file.c           libmagic        Makefile.global  run-tests.php
    config.guess    configure.ac  EXPERIMENTAL          libmagic.patch  missing          tests

     

  4.  ./configure --with-php-config=/usr/local/php/bin/php-config 【/usr/local/php/bin/ 是你自己的php目录】
    [root@izm5eb1zq3z60zvnqzti7yz fileinfo]# ./configure --with-php-config=/usr/local/php/bin/php-config

     

  5. 编译安装 ,如果出现【virtual memory exhausted: Cannot allocate memory】,查看https://blog.csdn.net/qq_34272964/article/details/82797587
    [root@izm5eb1zq3z60zvnqzti7yz fileinfo]# make && make install

     

  6.  修改php.ini文件,添加extension=fileinfo.so

    [root@izm5eb1zq3z60zvnqzti7yz fileinfo]# find  / -name php.ini
    /usr/local/php/etc/php.ini
    [root@izm5eb1zq3z60zvnqzti7yz fileinfo]# vim /usr/local/php/etc/php.ini
    

     

  7. 重启nginx服务器和php-fpm

    [root@izm5eb1zq3z60zvnqzti7yz sbin]# /usr/local/nginx/sbin/nginx -s stop
    [root@izm5eb1zq3z60zvnqzti7yz sbin]# /usr/local/nginx/sbin/nginx
    [root@izm5eb1zq3z60zvnqzti7yz fileinfo]# systemctl stop  php-fpm
    [root@izm5eb1zq3z60zvnqzti7yz fileinfo]# systemctl start php-fpm
    

     

你可能感兴趣的:(Linux,PHP,thinkPHP)