【7.2.18】
说明:此实例是在宝塔面板基础上进行安装扩展(原先我使用了apache2.8+php7.2.18+mysql5.6.27)

1.下载扩展

wget https://www.php.net/distributions/php-7.2.18.tar.gz

2.解压文件

tar -xvf php-7.2.18.tar.gz
3.打开目录

cd php-7.2.18/ext/fileinfo

4.直接执行以下命令 找不到 whice phpnize
/www/server/php/72/bin/phpize
返回:
Configuring for:
PHP Api Version: 20170718
Zend Module Api No: 20170718
Zend Extension Api No: 320170718
5.初始化配置
./configure --with-php-config=/www/server/php/72/bin/php-config
6.出现报错
make: * No targets specified and no makefile found. Stop.
virtual memory exhausted: Cannot allocate memory
显示内存不足 对于我的1GB小主机 使用不了 这时候需要创临时空间
解决办法:内存不足, 在linux下增加临时swap空间

参考《在linux下增加临时swap空间》
https://blog.csdn.net/qq_32642039/article/details/78070813?locationNum=7&fps=1

step 1:
  #sudo dd if=/dev/zero of=/home/swap bs=64M count=16
  注释:of=/home/swap,放置swap的空间; count的大小就是增加的swap空间的大小,64M就是块大小,这里是64MB,所以总共空间就是bs*count=1024MB.这里分配空间的时候需要一点时间,等待执行完毕。
  
step 2:
  # sudo mkswap /home/swap (可能会提示warning: don’t erase bootbits sectorson whole disk. Use -f to force,不用理会)
  注释:把刚才空间格式化成swap各式
step 3:
  #sudo swapon /home/swap
  注释:使刚才创建的swap空间

7.直接安装
make && make install

显示:

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.

8.配置扩展

vi /www/server/php/72/etc/php.ini
添加以下:
extension = /www/server/php/72/lib/php/extensions/no-debug-non-zts-20170718/fileinfo.so

标签: php7, php7.2.18, php7安装fileinfo