Red Hat 9下安装Remi PHP 8.2 gd扩展失败求助
问题:Red Hat 9上安装Remi PHP 8.2/8.3的php-gd扩展失败
已在Red Hat 9上部署Remi仓库,尝试安装Remi PHP 8.3的php-gd扩展时提示依赖缺失:package php-gd-8.3.17-1.el9.remi.x86_64 from remi-modular requires libgd.so.103()(64bit),切换到PHP 8.2时同样报错。
错误日志
[xxx@xxx yum.repos.d]$ sudo yum --enablerepo=remi install php-gd Updating Subscription Management repositories. Unable to read consumer identity This system is not registered with an entitlement server. You can use "rhc" or "subscription-manager" to register. Last metadata expiration check: 1:24:25 ago on Mon 03 Mar 2025 05:57:44 AM CET. Error: Problem: package php-gd-8.3.17-1.el9.remi.x86_64 from remi-modular requires libgd.so.103()(64bit), but none of the providers can be installed - cannot install the best candidate for the job - nothing provides libraqm.so.0()(64bit) needed by gd3php-2.3.3-8.el9.remi.x86_64 from remi - nothing provides libimagequant.so.0()(64bit) needed by gd3php-2.3.3-8.el9.remi.x86_64 from remi - nothing provides libavif.so.14()(64bit) needed by gd3php-2.3.3-8.el9.remi.x86_64 from remi - nothing provides libraqm.so.0()(64bit) needed by gd3php-2.3.3-9.el9.remi.x86_64 from remi - nothing provides libimagequant.so.0()(64bit) needed by gd3php-2.3.3-9.el9.remi.x86_64 from remi - nothing provides libraqm.so.0()(64bit) needed by gd3php-2.3.3-8.el9.remi.x86_64 from remi-safe - nothing provides libimagequant.so.0()(64bit) needed by gd3php-2.3.3-8.el9.remi.x86_64 from remi-safe - nothing provides libavif.so.14()(64bit) needed by gd3php-2.3.3-8.el9.remi.x86_64 from remi-safe - nothing provides libraqm.so.0()(64bit) needed by gd3php-2.3.3-9.el9.remi.x86_64 from remi-safe - nothing provides libimagequant.so.0()(64bit) needed by gd3php-2.3.3-9.el9.remi.x86_64 from remi-safe (try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)
当前PHP模块状态
系统中安装了多版本PHP,当前激活的是Remi PHP 8.3,模块列表如下:
[xxx@xxxx yum.repos.d]$ sudo dnf module list php [sudo] password for abera: Updating Subscription Management repositories. Unable to read consumer identity This system is not registered with an entitlement server. You can use "rhc" or "subscription-manager" to register. Last metadata expiration check: 1:46:52 ago on Mon 03 Mar 2025 05:50:52 AM CET. Remi's Modular repository for Enterprise Linux 9 - x86_64 Name Stream Profiles Summary php remi-7.4 common [d], devel, minimal PHP scripting language php remi-8.0 common [d], devel, minimal PHP scripting language php remi-8.1 common [d], devel, minimal PHP scripting language php remi-8.2 common [d], devel, minimal PHP scripting language php remi-8.3 [e] common [d] [i], devel, minimal PHP scripting language php remi-8.4 common [d], devel, minimal PHP scripting language ml-rhel9-dev-RHEL 9 x86_64 Appstream Name Stream Profiles Summary php 8.1 common [d], devel, minimal PHP scripting language php 8.2 common [d], devel, minimal PHP scripting language
已尝试操作
- 尝试搜索并安装缺失的依赖库:
sudo dnf search libraqm sudo dnf search libimagequant sudo dnf search libavif
但问题依旧,需解决Remi PHP 8.2的php-gd扩展安装问题。
解决方案
1. 启用Remi基础仓库
php-gd依赖的gd3php包位于Remi基础仓库(非modular仓库),先确保该仓库已启用:
sudo dnf config-manager --set-enabled remi
2. 切换到PHP 8.2模块
先重置并启用PHP 8.2模块:
sudo dnf module reset php -y sudo dnf module enable php:remi-8.2 -y
3. 安装php-gd及依赖
直接执行安装命令,dnf会自动从Remi仓库拉取所有所需依赖:
sudo dnf install php-gd -y
4. 验证安装
安装完成后,检查gd扩展是否成功加载:
php -m | grep gd
若仍有问题,可清理缓存后重新尝试:
sudo dnf clean all sudo dnf makecache sudo dnf install php-gd -y
内容的提问来源于stack exchange,提问作者Amit Bera
相关产品推荐
相关产品推荐

