先确认GD扩展是否安装,若未安装则根据操作系统通过包管理器安装对应版本,确保PHP版本匹配;接着在php.ini中启用extension=gd,最后重启服务并验证gd是否出现在php -m输出中。

这个提示说明你的 PHP 环境缺少 GD 扩展,而当前项目依赖它。GD 扩展用于图像处理,很多框架(如 Laravel)或库在生成验证码、缩略图时会用到。以下是解决方法。
php -m | grep -i gd
根据操作系统选择对应方式:
Ubuntu / Debian:sudo apt update<br>sudo apt install php-gd
sudo apt install php8.1-gd
sudo yum install php-gd
sudo dnf install php-gd
brew install php@8.1<br>brew link php@8.1
php --ini
;extension=gd
extension=gd
sudo systemctl restart apache2
sudo systemctl restart php-fpm
php -m | grep gd
基本上就这些。确保安装的 GD 版本与当前 PHP 版本一致,避免因多版本 PHP 导致配置错乱。
以上就是composer提示“The requested PHP extension gd is missing”如何解决?的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号