Centos 7.2 php 7.3 - 无法加载动态库 'gd'

Centos 7.2 php 7.3 - Unable to load dynamic library 'gd'

我安装了php-gd然后检查是否这样安装

[root@LP01-Dev ~]# php -v              // checking before installing gd
PHP 7.3.33 (cli) (built: Nov 16 2021 11:18:28) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.33, Copyright (c) 1998-2018 Zend Technologies
[root@LP01-Dev ~]# php -m | grep gd    // checking before installing gd

[root@LP01-Dev ~]# yum install php-gd  // installing gd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * epel: ftp.riken.jp
 * remi-php73: ftp.riken.jp
 * remi-safe: ftp.riken.jp
Resolving Dependencies
--> Running transaction check
---> Package php-gd.x86_64 0:7.3.33-1.el7.remi will be installed
--> Processing Dependency: gd-last(x86-64) >= 2.1.1 for package: php-gd-7.3.33-1.el7.remi.x86_64
--> Processing Dependency: libgd.so.3()(64bit) for package: php-gd-7.3.33-1.el7.remi.x86_64
--> Running transaction check
---> Package gd-last.x86_64 0:2.3.3-2.el7.remi will be installed
--> Processing Dependency: libraqm.so.0()(64bit) for package: gd-last-2.3.3-2.el7.remi.x86_64
--> Running transaction check
---> Package libraqm.x86_64 0:0.7.0-4.el7 will be installed
--> Processing Dependency: libfribidi.so.0()(64bit) for package: libraqm-0.7.0-4.el7.x86_64
--> Running transaction check
---> Package fribidi.x86_64 0:1.0.2-0.el7.remi will be installed
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================
 Package                 Arch                   Version                              Repository                  Size
======================================================================================================================
Installing:
 php-gd                  x86_64                 7.3.33-1.el7.remi                    remi-php73                  85 k
Installing for dependencies:
 fribidi                 x86_64                 1.0.2-0.el7.remi                     remi-safe                   79 k
 gd-last                 x86_64                 2.3.3-2.el7.remi                     remi-safe                  138 k
 libraqm                 x86_64                 0.7.0-4.el7                          epel                        15 k

Transaction Summary
======================================================================================================================
Install  1 Package (+3 Dependent packages)

Total download size: 317 k
Installed size: 948 k
Is this ok [y/d/N]: y
Downloading packages:
(1/4): php-gd-7.3.33-1.el7.remi.x86_64.rpm                                                     |  85 kB  00:00:00
(2/4): fribidi-1.0.2-0.el7.remi.x86_64.rpm                                                     |  79 kB  00:00:00
(3/4): libraqm-0.7.0-4.el7.x86_64.rpm                                                          |  15 kB  00:00:00
(4/4): gd-last-2.3.3-2.el7.remi.x86_64.rpm                                                     | 138 kB  00:00:00
----------------------------------------------------------------------------------------------------------------------
Total                                                                                 956 kB/s | 317 kB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : fribidi-1.0.2-0.el7.remi.x86_64                                                                    1/4
  Installing : libraqm-0.7.0-4.el7.x86_64                                                                         2/4
  Installing : gd-last-2.3.3-2.el7.remi.x86_64                                                                    3/4
  Installing : php-gd-7.3.33-1.el7.remi.x86_64                                                                    4/4
  Verifying  : gd-last-2.3.3-2.el7.remi.x86_64                                                                    1/4
  Verifying  : php-gd-7.3.33-1.el7.remi.x86_64                                                                    2/4
  Verifying  : libraqm-0.7.0-4.el7.x86_64                                                                         3/4
  Verifying  : fribidi-1.0.2-0.el7.remi.x86_64                                                                    4/4

Installed:
  php-gd.x86_64 0:7.3.33-1.el7.remi

Dependency Installed:
  fribidi.x86_64 0:1.0.2-0.el7.remi       gd-last.x86_64 0:2.3.3-2.el7.remi       libraqm.x86_64 0:0.7.0-4.el7

Complete!

我安装gd后,出现这个错误。

[root@LP01-Dev ~]# php -v          // can't load gd with this warning
PHP Warning:  PHP Startup: Unable to load dynamic library 'gd' (tried: /usr/lib64/php/modules/gd (/usr/lib64/php/modules/gd: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/gd.so (/lib64/libraqm.so.0: undefined symbol: hb_ft_font_set_load_flags)) in Unknown on line 0
PHP 7.3.33 (cli) (built: Nov 16 2021 11:18:28) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.33, Copyright (c) 1998-2018 Zend Technologies

首先,我检查是否没有gd文件。

[root@LP01-Dev ~]# cd /usr/lib64/php/modules/
[root@LP01-Dev modules]# ll
total 6212
-rwxr-xr-x 1 root root   24360 Nov 17 00:19 bz2.so
-rwxr-xr-x 1 root root   32408 Nov 17 00:19 calendar.so
-rwxr-xr-x 1 root root   15536 Nov 17 00:19 ctype.so
-rwxr-xr-x 1 root root   86968 Nov 17 00:19 curl.so
-rwxr-xr-x 1 root root   86064 Nov 17 00:19 exif.so
-rwxr-xr-x 1 root root 5428968 Nov 17 00:19 fileinfo.so
-rwxr-xr-x 1 root root   62048 Nov 17 00:19 ftp.so
-rwxr-xr-x 1 root root  108344 Nov 17 00:19 gd.so    # Here is!
-rwxr-xr-x 1 root root   15656 Nov 17 00:19 gettext.so
-rwxr-xr-x 1 root root   45072 Nov 17 00:19 iconv.so
-rwxr-xr-x 1 root root   44776 Nov 17 00:19 json.so
-rwxr-xr-x 1 root root  273688 Nov 17 00:19 phar.so
-rwxr-xr-x 1 root root   91576 Nov 17 00:19 sockets.so
-rwxr-xr-x 1 root root   19856 Nov 17 00:19 tokenizer.so

我想知道我是否应该将文件作为确切的名称放置 'gd'。所以我将 'gd.so' 文件复制到同一位置的 'gd'。

[root@LP01-Dev modules]# cp gd.so gd
[root@LP01-Dev modules]# ll
total 6320
-rwxr-xr-x 1 root root   24360 Nov 17 00:19 bz2.so
-rwxr-xr-x 1 root root   32408 Nov 17 00:19 calendar.so
-rwxr-xr-x 1 root root   15536 Nov 17 00:19 ctype.so
-rwxr-xr-x 1 root root   86968 Nov 17 00:19 curl.so
-rwxr-xr-x 1 root root   86064 Nov 17 00:19 exif.so
-rwxr-xr-x 1 root root 5428968 Nov 17 00:19 fileinfo.so
-rwxr-xr-x 1 root root   62048 Nov 17 00:19 ftp.so
-rwxr-xr-x 1 root root  108344 Feb 26 18:27 gd          # Also here!
-rwxr-xr-x 1 root root  108344 Nov 17 00:19 gd.so
-rwxr-xr-x 1 root root   15656 Nov 17 00:19 gettext.so
-rwxr-xr-x 1 root root   45072 Nov 17 00:19 iconv.so
-rwxr-xr-x 1 root root   44776 Nov 17 00:19 json.so
-rwxr-xr-x 1 root root  273688 Nov 17 00:19 phar.so
-rwxr-xr-x 1 root root   91576 Nov 17 00:19 sockets.so
-rwxr-xr-x 1 root root   19856 Nov 17 00:19 tokenizer.so

但出现了不同的错误。

[root@LP01-Dev modules]# php -v
PHP Warning:  PHP Startup: Unable to load dynamic library 'gd' (tried: /usr/lib64/php/modules/gd (/lib64/libraqm.so.0: undefined symbol: hb_ft_font_set_load_flags), /usr/lib64/php/modules/gd.so (/lib64/libraqm.so.0: undefined symbol: hb_ft_font_set_load_flags)) in Unknown on line 0
PHP 7.3.33 (cli) (built: Nov 16 2021 11:18:28) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.33, Copyright (c) 1998-2018 Zend Technologies

我搜索了这个错误 /lib64/libraqm.so.0:未定义的符号:hb_ft_font_set_load_flags 然后我发现有人和我有类似(几乎相同)的问题。 Link --> php-gd installed but fails to function in centos 7 (php 7.3 version)

所以我尝试了 link 中的两个答案。

第一个。 答案说 hb_ft_font_set_load_flags 来自 HarfBuzz,所以我尝试安装它。

[root@LP01-Dev modules]# yum install harfbuzz
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * epel: ftp.riken.jp
 * remi-php73: ftp.riken.jp
 * remi-safe: ftp.riken.jp
Package harfbuzz-0.9.36-1.el7.x86_64 already installed and latest version
Nothing to do

我好像已经有了 harfbuzz..

我尝试了第二个答案

[root@LP01-Dev lib64]# yum provides '*/libraqm.so*'    // checking..
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * epel: ftp.riken.jp
 * remi-php73: ftp.riken.jp
 * remi-safe: ftp.riken.jp
libraqm-0.7.0-4.el7.x86_64 : Complex Textlayout Library
Repo        : epel
Matched from:
Filename    : /usr/lib64/libraqm.so.0.700.0
Filename    : /usr/lib64/libraqm.so.0



libraqm-devel-0.7.0-4.el7.x86_64 : Complex Textlayout Library
Repo        : epel
Matched from:
Filename    : /usr/lib64/libraqm.so



libraqm-0.7.0-4.el7.x86_64 : Complex Textlayout Library
Repo        : @epel
Matched from:
Filename    : /usr/lib64/libraqm.so.0.700.0
Filename    : /usr/lib64/libraqm.so.0



[root@LP01-Dev lib64]# cd ~
[root@LP01-Dev ~]# ll /usr/lib64/libraqm.so*           // checking..
lrwxrwxrwx 1 root root    18 Feb 26 18:16 /usr/lib64/libraqm.so.0 -> libraqm.so.0.700.0
-rwxr-xr-x 1 root root 19792 Jan 11  2020 /usr/lib64/libraqm.so.0.700.0

我也查看了/lib64目录下有没有libraqm.so.0文件

[root@LP01-Dev ~]# cd /lib64
[root@LP01-Dev lib64]# ll
total 100984
drwxr-xr-x.  3 root root     4096 Dec 26  2016 alsa-lib
drwxr-xr-x.  2 root root     4096 Jun 10  2014 apr-util-1
drwxr-xr-x.  2 root root     4096 Apr  7  2017 audit
.
.
.
lrwxrwxrwx   1 root root       18 Feb 26 18:16 libraqm.so.0 -> libraqm.so.0.700.0     # Here!
-rwxr-xr-x   1 root root    19792 Jan 11  2020 libraqm.so.0.700.0
.
.
.
dr-xr-xr-x.  2 root root     4096 Aug 12  2015 tls
dr-xr-xr-x.  2 root root     4096 Aug 12  2015 X11
drwxr-xr-x.  2 root root     4096 Dec 26  2016 xtables

似乎我在 /usr/lib64 和 /lib64 目录中都没有 libraqm.so 文件.. 所以我应该安装 libraqm-devel 吗?我不确定,但我试过了。

[root@LP01-Dev lib64]# yum install libraqm-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * epel: ftp.riken.jp
 * remi-php73: ftp.riken.jp
 * remi-safe: ftp.riken.jp
Resolving Dependencies
--> Running transaction check
---> Package libraqm-devel.x86_64 0:0.7.0-4.el7 will be installed
--> Processing Dependency: pkgconfig(fribidi) for package: libraqm-devel-0.7.0-4.el7.x86_64
--> Running transaction check
---> Package fribidi-devel.x86_64 0:0.19.4-6.el7 will be installed
--> Processing Dependency: fribidi(x86-64) = 0.19.4-6.el7 for package: fribidi-devel-0.19.4-6.el7.x86_64
--> Finished Dependency Resolution
Error: Package: fribidi-devel-0.19.4-6.el7.x86_64 (base)
           Requires: fribidi(x86-64) = 0.19.4-6.el7
           Installed: fribidi-1.0.2-0.el7.remi.x86_64 (@remi-safe)
               fribidi(x86-64) = 1.0.2-0.el7.remi
           Available: fribidi-0.19.4-6.el7.x86_64 (base)
               fribidi(x86-64) = 0.19.4-6.el7
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

我无法安装.. 我应该降级 fribidi 吗? 我真的不知道..我重新启动并尝试重置 OS 几次..

我明天会找到更多的方法,但我感到很沮丧所以我写了这个问题..希望有人能帮助我。谢谢~!

Centos 7.2 php 7.3

这里的主要问题是您使用的是过时的 CentOS 版本:

  • 7.2 于 2015 年发布...不再维护
  • 当前为 7.9,2020 年发布

所以您需要先更新到最新版本(特别是因为您缺少 7 年的安全性 更新)

# cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)

# rpm -q php-gd gd-last fribidi libraqm harfbuzz
php-gd-7.3.33-1.el7.remi.x86_64
gd-last-2.3.3-2.el7.remi.x86_64
fribidi-1.0.2-1.el7_7.1.x86_64
libraqm-0.7.0-4.el7.x86_64
harfbuzz-1.7.5-2.el7.x86_64

# php --ri gd

gd

GD Support => enabled
GD headers Version => 2.3.3
GD library Version => 2.3.3
FreeType Support => enabled
FreeType Linkage => with freetype
FreeType Version => 2.8.0
GIF Read Support => enabled
GIF Create Support => enabled
JPEG Support => enabled
libJPEG Version => 6b
PNG Support => enabled
libPNG Version => 1.5.13
WBMP Support => enabled
XPM Support => enabled
libXpm Version => 30411
XBM Support => enabled
WebP Support => enabled

Directive => Local Value => Master Value
gd.jpeg_ignore_warning => 1 => 1

Package harfbuzz-0.9.36-1.el7.x86_64 already installed and latest version

所以问题来了,harfbuzz 在 CentOS 7.4 (2017) 中更新为 1.3.2,在 CentOS 7.6 (2018) 中更新为 1.7.5

注意:PHP7.3 也停产了。