宝塔面板php8.1安装fileinfo失败或无法安装的解决方案

  • Post author:
  • Post category:php


宝塔面板安装php8.1的fileinfo错误,网上说修改swap大小我试过基本都没什么用

/bin/sh /www/server/php/81/src/ext/fileinfo/libtool --mode=compile /opt/rh/devtoolset-7/root/usr/bin/gcc -I. -I/www/server/php/81/src/ext/fileinfo -I/www/server/php/81/src/ext/fileinfo/include -I/www/server/php/81/src/ext/fileinfo/main -I/www/server/php/81/src/ext/fileinfo -I/www/server/php/81/include/php -I/www/server/php/81/include/php/main -I/www/server/php/81/include/php/TSRM -I/www/server/php/81/include/php/Zend -I/www/server/php/81/include/php/ext -I/www/server/php/81/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -I/www/server/php/81/src/ext/fileinfo/libmagic -DZEND_COMPILE_DL_EXT=1 -c /www/server/php/81/src/ext/fileinfo/libmagic/softmagic.c -o libmagic/softmagic.lo  -MMD -MF libmagic/softmagic.dep -MT libmagic/softmagic.lo
 /opt/rh/devtoolset-7/root/usr/bin/gcc -I. -I/www/server/php/81/src/ext/fileinfo -I/www/server/php/81/src/ext/fileinfo/include -I/www/server/php/81/src/ext/fileinfo/main -I/www/server/php/81/src/ext/fileinfo -I/www/server/php/81/include/php -I/www/server/php/81/include/php/main -I/www/server/php/81/include/php/TSRM -I/www/server/php/81/include/php/Zend -I/www/server/php/81/include/php/ext -I/www/server/php/81/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -I/www/server/php/81/src/ext/fileinfo/libmagic -DZEND_COMPILE_DL_EXT=1 -c /www/server/php/81/src/ext/fileinfo/libmagic/softmagic.c -MMD -MF libmagic/softmagic.dep -MT libmagic/softmagic.lo  -fPIC -DPIC -o libmagic/.libs/softmagic.o
In file included from /usr/include/string.h:633:0,
                 from /www/server/php/81/include/php/main/../main/php_config.h:2210,
                 from /www/server/php/81/include/php/Zend/zend_config.h:1,
                 from /www/server/php/81/include/php/Zend/zend_portability.h:43,
                 from /www/server/php/81/include/php/Zend/zend_types.h:25,
                 from /www/server/php/81/include/php/Zend/zend.h:27,
                 from /www/server/php/81/include/php/main/php.h:31,
                 from /www/server/php/81/src/ext/fileinfo/libmagic/config.h:1,
                 from /www/server/php/81/src/ext/fileinfo/libmagic/file.h:36,
                 from /www/server/php/81/src/ext/fileinfo/libmagic/softmagic.c:32:
/www/server/php/81/src/ext/fileinfo/libmagic/softmagic.c:507:7: error: expected identifier or ‘(’ before ‘__extension__’
 char *strndup(const char *, size_t);
       ^
/www/server/php/81/src/ext/fileinfo/libmagic/softmagic.c:510:1: error: expected identifier or ‘(’ before ‘__extension__’
 strndup(const char *str, size_t n)
 ^
make: *** [libmagic/softmagic.lo] Error 1
error

处理方式:

cd /www/server/php/81/src/ext/fileinfo/
/www/server/php/81/bin/phpize
./configure --with-php-config=/www/server/php/81/bin/php-config
sed -i "s#CFLAGS = -g -O2#CFLAGS = -std=c99 -g#g" Makefile
make && make install
echo "extension=/www/server/php/81/lib/php/extensions/no-debug-non-zts-20210902/fileinfo.so" >> /www/server/php/81/etc/php.ini
echo "extension=/www/server/php/81/lib/php/extensions/no-debug-non-zts-20210902/fileinfo.so" >> /www/server/php/81/etc/php-cli.ini
/etc/init.d/php-fpm-81 restart

然后去看fileinfo插件就安装成功了



版权声明:本文为memeguigui原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。