【问题标题】:AWS EC2 Wordpress - gd module not enabledAWS EC2 Wordpress - 未启用 gd 模块
【发布时间】: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=gd20extension=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


    【解决方案1】:

    希望你已经解决了这个问题,原因可能是你有用于 centos 的包 GD 包,但没有用于 PHP 模块的包。 '

    对于 PHP 8.0,以下命令应该能够正确安装和启用包。

    sudo apt-get install php8.0-gd

    请尝试使用yum search all package_name 搜索gdphp-gd

    建议安装后重启apache。

    请在此处参考原始来源。 Original Source

    【讨论】:

    • 感谢您的回复!我在我的机器上找到了你所指的包:php-gd 8.0.6。我尝试重新启动 Apache,但似乎没有任何改变。我也尝试将扩展命令更改为extension=php-gd,但同样似乎没有任何改变。
    • @FedericoScitittaro 尝试安装它,yum 在安装 PHP 模块时帮助了我好几次,也会自动为这些模块创建一个 .ini 文件。
    • 所以我应该卸载然后重新安装它?
    • 你可以试试,但我有更好的建议,你可以试试easyengine来满足同样的要求吗,谷歌它基本上是为LEMP堆栈和所有SSL开发的。请在google上搜索easyengine,希望能解决您面临的所有这些问题。
    • 像往常一样,答案是“将其关闭并重新打开”。 service httpd restart 没有改变任何东西。因此,我尝试了pkill httpd,然后尝试了service httpd start ...并且成功了!
    猜你喜欢
    • 1970-01-01
    • 2020-12-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-30
    • 2023-03-31
    • 2019-07-03
    相关资源
    最近更新 更多