【发布时间】:2021-09-04 01:01:01
【问题描述】:
我正在尝试使用运行 CentOS 的 AWS EC2 实例部署 Wordpress 网站。我正在使用 wordpress 5.7.2、PHP 8.0.6 和 Apache 2.4.46。我已成功启动并运行网站,但在我的网站健康状态中看到以下问题:
The required module, gd, is not installed, or has been disabled.
我知道我已经安装了gd,因为当我通过 SSH 连接到我的实例并键入 sudo yum info gd 命令时,我会收到以下输出:
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.
那么,问题应该是如何启用gd。我的/etc/php.ini 文件不包含任何扩展命令,因为我的站点设置为在/etc/php.d 目录中找到所有扩展命令。我在该目录中有一个文件/etc/php.d/20-gd.ini,如下所示:
; Enable gd extension module
extension=gd
虽然看起来设置正确,但这似乎不起作用,因为当我检查我的phpinfo.php 时,它显示有几个其他模块的格式完全相同,并且正在成功加载:
/etc/php.d 目录中除20-gd.ini 之外的每个文件都被此设置正确解析。我尝试手动将extension=gd 命令直接添加到php.ini 文件中并在我的EC2 实例中执行service httpd restart,但这并没有改变任何东西。我还尝试输入其他版本的gd,例如extension=gd20 或extension=gd.so,但没有任何成功。什么可能导致此问题?
编辑:根据found here 的建议,我在我的 EC2 实例中执行了php --ini 命令,这表明/etc/php.d/20-gd.ini 实际上出现了:
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
...
所以它出现在这里,但由于某种原因不在phpinfo() 中。将尝试找出原因。
【问题讨论】:
标签: php wordpress amazon-web-services amazon-ec2 gd