1.首先检查系统是否已经安装
[root@iZbp1dwql3ymcem09rfdchZ ~]# php -i|grep fileinfo
Configure Command => './configure' '--prefix=/alidata/server/php' '--enable-opcache' '--with-config-file-path=/alidata/server/php/etc' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--enable-fpm' '--enable-fastcgi' '--enable-static' '--enable-inline-optimization' '--enable-sockets' '--enable-wddx' '--enable-zip' '--enable-calendar' '--enable-bcmath' '--enable-soap' '--with-zlib' '--with-iconv' '--with-gd' '--with-xmlrpc' '--enable-mbstring' '--without-sqlite' '--with-curl' '--enable-ftp' '--with-mcrypt' '--with-freetype-dir=/usr/local/freetype.2.1.10' '--with-jpeg-dir=/usr/local/jpeg.6' '--with-png-dir=/usr/local/libpng.1.2.50' '--disable-ipv6' '--disable-debug' '--with-openssl' '--disable-maintainer-zts' '--disable-safe-mode' '--disable-fileinfo'
fileinfo
fileinfo support => enabled
如果出现上面说明已经安装(或者phpinfo查找【fileinfo】,没有则进行下面步骤)
2.执行下载包含fileinfo扩展的php安装包命令,也可以独立下载fileinfo编译安装包
首先进入php所在目录(避免文件杂乱--非必须):cd /usr/local/php/
wget -O php-5.6.36.tar.gz http://cn2.php.net/get/php-5.6.36.tar.gz/from/this/mirror
3.解压
tar -zxvf php-5.6.36.tar.gz
4.当前目录解压完,进入下面目录
cd php-5.6.36/ext/fileinfo/
5.在之前已经编译安装的的php的bin目录中找到命令phpize执行生成.configure文件(核心:找到phpinfo中phpize和php-config的路径)
/usr/local/php/bin/phpize
6.配置、编译安装
./configure -with-php-config=/usr/local/php/bin/php-config
make && make install
7.修改php.ini
加入extension=fileinfo.so
8.重启服务器,完成
