欢迎关注颖小主的个人博客
服务器环境: 宝塔7.7.0
操作系统: Alibaba Cloud (Aliyun ) 2.1903 LTS (Hunting Beagle) x86_64(Py3.7.9)
php版本: 8,0
直接使用宝塔中的php扩展安装
但是在我安装的情况下,一直安装失败。查看日志信息大概看到报错原因是这样的:
... /www/server/php/80/src/ext/fileinfo/libmagic/funcs.c: In function ‘file_checkfmt’: /www/server/php/80/src/ext/fileinfo/libmagic/funcs.c:97:2: error: ‘for’ loop initial declarations are only allowed in C99 mode for (const char *p = fmt; *p; p++) { ^ ...
我从宝塔官网上,找到了有人关于这个bug的上报信息,给的回复大概意思就是阿里云自己封装后的系统,宝塔这里不兼容,建议使用centos8,有兴趣点击这里进行查看
所以我就从网上开启了面向百度编程模式,来了一波骚操作
通过自己手动编译的方式进行安装fileinfo
[root@iZ2zej0uggzcedouxtbhq4Z php]# find / -name fileinfo /www/server/php/74/src/ext/fileinfo /www/server/php/73/src/ext/fileinfo /www/server/php/80/src/ext/fileinfo
/www/server/php/80/bin/phpize
./configure --with-php-config=/www/serve/php/80/bin/php-config
make && make install
# 执行这个命令 /www/server/php/80/bin/phpize [root@iZ2zej0uggzcedouxtbhq4Z fileinfo]# /www/server/php/80/bin/phpize Configuring for: PHP Api Version: 20200930 Zend Module Api No: 20200930 Zend Extension Api No: 420200930 # 接着执行一下这个命令 ./configure --with-php-config=/www/serve/php/80/bin/php-config [root@iZ2zej0uggzcedouxtbhq4Z fileinfo]# ./configure --with-php-config=/www/serve/php/80/bin/php-config checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for a sed that does not truncate output... /usr/bin/sed checking for pkg-config... /usr/bin/pkg-config checking pkg-config is at least version 0.9.0... yes checking for cc... cc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o .... # 执行一下这个命令 make && make install [root@iZ2zej0uggzcedouxtbhq4Z fileinfo]# make && make install ... /www/server/php/80/src/ext/fileinfo/libmagic/funcs.c: In function ‘file_checkfmt’: /www/server/php/80/src/ext/fileinfo/libmagic/funcs.c:97:2: error: ‘for’ loop initial declarations are only allowed in C99 mode for (const char *p = fmt; *p; p++) { ^ /www/server/php/80/src/ext/fileinfo/libmagic/funcs.c:97:2: note: use option -std=c99 or -std=gnu99 to compile your code # 依然报错
上边依然报错,解决办法,修改Makefile文件
大概在25行,将CFLAGS = -g -02
修改为 ``CFLAGS = -std=c99 -g -02`
然后在执行一次make && make install
顺利安装成功
欢迎关注颖小主的个人博客