已安装 php-gd 但在 centos 7(php 7.3 版本)中无法运行

Posted

技术标签:

【中文标题】已安装 php-gd 但在 centos 7(php 7.3 版本)中无法运行【英文标题】:php-gd installed but fails to function in centos 7 (php 7.3 version) 【发布时间】:2020-05-06 15:06:21 【问题描述】:

我正在尝试安装moodle,但它显示php-gd 扩展丢失/应该启用。 但是 gd 已经安装并且是最新的,当我命令 php -v 时,我收到以下错误,如下所示。

PHP Warning:  PHP Startup: Unable to load dynamic library 'gd.so' (tried: /usr/lib64/php/modules/gd.so (/lib64/libraqm.so.0: undefined symbol: hb_ft_font_set_load_flags), /usr/lib64/php/modules/gd.so.so (/usr/lib64/php/modules/gd.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP 7.3.17 (cli) (built: Apr 14 2020 08:29:22) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.17, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.17, Copyright (c) 1999-2018, by Zend Technologies

我做了很多编辑,但找不到一个解决方案。请帮忙

【问题讨论】:

这个命令的输出是什么:php -m | grep gd 你是如何安装 gd 模块的? 这里是 rpm -qa|grep gd 的输出,我使用 yum install php-gdgdm-gdm-3.8.4-27.el7.x86_64 gd-last-2.3.0-1.el7 .remi.x86_64 libgdither-0.6-8.el7.x86_64 php-gd-7.3.17-1.el7.remi.x86_64 gdisk-0.8.6-4.el7.x86_64 gdbm-1.10-8.el7.x86_64 libs- 3.8.4-27.el7.x86_64 gd-devel-2.0.35-26.el7.x86_64 gupnp-igd-0.2.2-3.el7.x86_64 gdb-7.6.1-51.el7.x86_64 gd-2.0。 35-26.el7.x86_64 pulseaudio-gdm-hooks-3.0-22.el7.x86_64 cgdcbxd-1.0.2-5.el7.x86_64 php73-php-gd-7.3.17-1.el7.remi.x86_64 libgdata- 0.13.3-4.el7.x86_64 gdk-pixbuf2-2.28.2-4.el7.x86_64 @DavidHlavati 如果我运行 php -m | grep gd //I GET //// PHP Startup: Unable to load dynamic library 'gd' (试过: /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)) 在Unknown on line 0 您安装了所有列出的软件包吗? 【参考方案1】:

我遇到了同样的问题:

# php --version
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.2.32 (cli) (built: Jul  8 2020 07:33:50) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.32, Copyright (c) 1999-2018, by Zend Technologies

在 google 上的快速搜索告诉我 hb_ft_font_set_load_flags 来自 HarfBuzz (https://harfbuzz.github.io/harfbuzz-hb-ft.html)。

我用yum install harfbuzz安装了它,然后警告就消失了:

php --version
PHP 7.2.32 (cli) (built: Jul  8 2020 07:33:50) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.32, Copyright (c) 1999-2018, by Zend Technologies

【讨论】:

【参考方案2】:

运行:

yum install libraqm-devel
[root@* ~]# yum provides '*/libraqm.so*'
Repository epel is listed more than once in the configuration
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


[root@* ~]# ll /usr/lib64/libraqm.so*
lrwxrwxrwx 1 root root    18 Jul 20 23:20 /usr/lib64/libraqm.so -> libraqm.so.0.700.0
lrwxrwxrwx 1 root root    18 Jul 18 19:00 /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

libraqm.solibraqm-devel提供。

安装libraqm-devel 还会安装freetype 和harfbuzz,它们提供hb_ft_font_set_load_flags

【讨论】:

请在您的答案中添加一些解释,以便其他人可以从中学习

以上是关于已安装 php-gd 但在 centos 7(php 7.3 版本)中无法运行的主要内容,如果未能解决你的问题,请参考以下文章

CentOS 7 安装iTop

尝试在 Docker 官方镜像中添加 freetype 到 php-gd

centos6-7 yum安装php的方法

centos6-7 yum安装php的方法

centos yum安装PHP5.5,5.6,7.0

如何在CentOS 7安装和配置ownCloud