WordPress_可选的模组exif未被安装或已被禁用

WordPress_可选的模组exif未被安装或已被禁用

wordpress后台显示站点有健康问题:可选的模组exif未被安装或已被禁用

1.先查看当前系统的php版本

[root@LNMP ~]# php -v
PHP 7.4.8 (cli) (built: Mar  9 2023 07:50:45) ( ZTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

原本已有php-7.4.8.tar.gz的不需要下载

image-20230907235331916

没有的话,请下载

wget https://www.php.net/distributions/php-7.4.8.tar.bz2 

解压缩

tar -xvf php-7.4.8.tar

2.在ext目录下编译安装

进入 php-7.4.8 安装目录的模组文件夹并查看

cd ./php-7.4.8/ext/exif
/usr/local/php/bin/phpize
Configuring for:
PHP Api Version:         20190902
Zend Module Api No:      20190902
Zend Extension Api No:   320190902

进行安装配置

./configure --with-php-config=/usr/local/php/bin/php-config

编译

make 

3.可能出现的问题

可能会出现下面的报错(如没有出现,请跳过)

/usr/local/src/php-8.1.31/ext/exif/exif.c:2483:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (int i = 0; i<image_info->info_list[section_index].count; i++) {
  ^
/usr/local/src/php-8.1.31/ext/exif/exif.c:2483:2: note: use option -std=c99 or -std=gnu99 to compile your code
/usr/local/src/php-8.1.31/ext/exif/exif.c:2536:6: error: ‘for’ loop initial declarations are only allowed in C99 mode
      for (int ap = 0; ap < l; ap++) {
      ^
/usr/local/src/php-8.1.31/ext/exif/exif.c:2544:10: error: ‘for’ loop initial declarations are only allowed in C99 mode
          for (int b = 0; b < l; b++) {
          ^
/usr/local/src/php-8.1.31/ext/exif/exif.c:2571:10: error: ‘for’ loop initial declarations are only allowed in C99 mode
          for (int b = 0; b < l; b++) {
          ^
make: *** [exif.lo] Error 1

4.解决方法:

设置C编译器的标准为C99

在编译前,通过CFLAGS环境变量制定编译器使用C99标准:

export CFLAGS="-std=c99"

5.再次编译安装

再次进入exif扩展目录

确保在PHP源码的ext/exif目录下操作

cd /usr/local/src//php-7.4.8/ext/exif

重新生成配置

phpize --clean
phpize

再次运行configure脚本

./configure --with-php-config=/usr/local/php/bin/php-config

再次进行编译和安装

make && sudo make install

6.修改配置文件

在文件里面新增extension = “exif.so”

[root@LNMP exif]# vim /usr/local/php/php.ini
image-20230908001413932

重启PHP,并查看wordpress是否少了一个健康问题

[root@LNMP exif]# service php-fpm restart

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注