Centos 7.2 php 7.3 - 無法載入動態库 'gd'

  • 本文关键字:gd php Centos php centos7 php-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然后我发现有人和我有类似(几乎相同(的问题。链接-->php-gd已安装,但无法在centos 7(php7.3版本(中运行

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

第一个。https://stackoverflow.com/a/63196532/10651708答案是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

看来我已经有了哈夫布兹。。

我试着回答第二个问题https://stackoverflow.com/a/62998791/10651708

[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吗?我真的不知道。。我重新启动,也尝试过几次重置操作系统。。

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

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

包harfbuzz-0.9.36-1.el7.x86_64已安装和最新版本

所以问题来了,harfbuzz在Centos7.4(2017(中更新到1.3.2,在Centos7.6(2018(中更新到1.7.5

注意:PHP 7.3也是EOL。

最新更新