AWS EC2 Wordpress - gd module not enabled

I am trying to deploy a Wordpress website using an AWS EC2 instance running CentOS. I am using wordpress 5.7.2, PHP 8.0.6, and Apache 2.4.46. I have gotten the website up and running successfully, but am seeing the following issue in my Site Health Status:

The required module, gd, is not installed, or has been disabled.

I know that I already have gd installed, because when I SSH into my instance and type the sudo yum info gd command, I receive the following output:

Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
Available Packages
Name        : gd
Arch        : i686
Version     : 2.0.35
Release     : 27.amzn2
Size        : 149 k
Repo        : amzn2-core/2/x86_64
Summary     : A graphics library for quick creation of PNG or JPEG images
URL         : http://www.libgd.org/Main_Page
License     : MIT
Description : The gd graphics library allows your code to quickly draw images
            : complete with lines, arcs, text, multiple colors, cut and paste from
            : other images, and flood fills, and to write out the result as a PNG or
            : JPEG file. This is particularly useful in Web applications, where PNG
            : and JPEG are two of the formats accepted for inline images by most
            : browsers. Note that gd is not a paint program.

Name        : gd
Arch        : x86_64
Version     : 2.0.35
Release     : 27.amzn2
Size        : 146 k
Repo        : amzn2-core/2/x86_64
Summary     : A graphics library for quick creation of PNG or JPEG images
URL         : http://www.libgd.org/Main_Page
License     : MIT
Description : The gd graphics library allows your code to quickly draw images
            : complete with lines, arcs, text, multiple colors, cut and paste from
            : other images, and flood fills, and to write out the result as a PNG or
            : JPEG file. This is particularly useful in Web applications, where PNG
            : and JPEG are two of the formats accepted for inline images by most
            : browsers. Note that gd is not a paint program.

So then, the issue should be how to enable gd. My /etc/php.ini file does not contain any extension commands because my site is set up such that all the extension commands are found inside the /etc/php.d directory. I have a file inside that directory, /etc/php.d/20-gd.ini, that looks as follows:

; Enable gd extension module
extension=gd

This doesn't seem to work although it looks set up correctly, because when I check my phpinfo.php, it shows me that there are several other modules formatted the exact same way that are being loaded in successfully:

enter image description here

Every file inside the /etc/php.d directory except for 20-gd.ini is being parsed correctly by this set-up. I have tried manually adding the extension=gd command directly into the php.ini file and executed service httpd restart inside my EC2 instance, but that didn't change anything. I've also experimented with typing in other versions of gd such as extension=gd20 or extension=gd.so, but without any success. What could be causing this issue?

EDIT: Per the suggestion found here, I executed the php --ini command in my EC2 instance, which shows that /etc/php.d/20-gd.ini is in fact showing up:

Configuration File (php.ini) Path: /etc
Loaded Configuration File:         /etc/php.ini
Scan for additional .ini files in: /etc/php.d
Additional .ini files parsed:      /etc/php.d/20-bz2.ini,
/etc/php.d/20-calendar.ini,
/etc/php.d/20-ctype.ini,
/etc/php.d/20-curl.ini,
/etc/php.d/20-exif.ini,
/etc/php.d/20-fileinfo.ini,
/etc/php.d/20-ftp.ini,
/etc/php.d/20-gd.ini
...

So it's showing up here, but not in phpinfo() for some reason. Will try to figure out why.

1 answer

  • answered 2021-06-19 18:22 Gautam Jha

    Hope you have resolved the issue, the reason for this could you have the package GD package for centos but not for PHP modules. '

    For PHP 8.0 the following command should be able to install and enable the package correctly.

    sudo apt-get install php8.0-gd

    Please try to search for gd or php-gd with yum search all package_name.

    Restarting apache after installation is recommended.

    Please refer to the original source here. Original Source