php 启用/安装 GD 扩展?--没有-gd

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2283199/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 05:52:07  来源:igfitidea点击:

Enabling/installing GD extension? --without-gd

phpamazon-ec2gd

提问by Shu

How does one enable (or perhaps I need to install) GD when my phpinfo() output in "Configure Command" says; --without-gd ?

当“配置命令”中的 phpinfo() 输出显示时,如何启用(或者我可能需要安装)GD;--没有-gd?

I also have nothing in my phpinfo() output "Core" that lists "gd"

我的 phpinfo() 输出“Core”中也没有列出“gd”的内容

PHP Version 5.2.4 on AWS.

AWS 上的 PHP 版本 5.2.4。

回答by Shane

if you are on a Debian based server (such as Ubuntu) you can run the following command:

如果您使用的是基于 Debian 的服务器(例如 Ubuntu),您可以运行以下命令:

apt-get install php5-gd

Then once it is complete run:

然后一旦完成运行:

/etc/init.d/apache2 restart

This will restart your server and enable GD in PHP.

这将重新启动您的服务器并在 PHP 中启用 GD。

If you are on another type of system you will need to use something else (like yum install) or compile directly into PHP.

如果您在其他类型的系统上,您将需要使用其他东西(如 yum install)或直接编译成 PHP。

回答by Sebastian Viereck

For PHP7.0 use (php7.1-gd, php7.2-gdand php7.3-gdare also available):

对于 PHP7.0 使用(php7.1-gd、php7.2-gdphp7.3-gd也可用):

sudo apt-get install php7.0-gd

and than restart your webserver.

然后重新启动您的网络服务器。

回答by Leonardo Camargo

Check if in your php.ini file has the following line:

检查您的 php.ini 文件中是否有以下行:

;extension=php_gd2.dll

if exists, change it to

如果存在,将其更改为

extension=php_gd2.dll

and restart apache

并重新启动apache

(it works on MAC)

(它适用于 MAC)

回答by Vindesh Mohariya

In my case (php 5.6, Ubuntu 14.04) the following command worked for me:

就我而言 ( php 5.6, Ubuntu 14.04) 以下命令对我有用:

sudo apt-get install php5.6-gd

According to php version we need to change the php5.x-gd

根据 php 版本,我们需要更改 php5.x-gd

回答by Alexandre Bourlier

All previous answers are correct but were not sufficient for me on ArchLinux. I also needed to edit /etc/php/php.iniand to uncomment :

以前的所有答案都是正确的,但在 ArchLinux 上对我来说还不够。我还需要编辑/etc/php/php.ini和取消注释:

;extension=gd.so 

The initial ;on the line needs to be removed. After restarting Nginx via systemctl restart nginx, I was good to go.

;行上的首字母需要删除。通过 重新启动 Nginx 后systemctl restart nginx,我很高兴。

回答by Mubashar Abbas

For php7.1do:

对于php7.1做:

sudo apt-get install php7.1-gd

and restart webserver. For apachedo

并重新启动网络服务器。为apache

sudo service apache2 restart

回答by Nayan Thakkar

If You're using php5.6 and Ubuntu 18.04 Then run these two commands in your terminal your errors will be solved definitely.

如果您使用的是 php5.6 和 Ubuntu 18.04 然后在终端中运行这两个命令,您的错误肯定会得到解决。

sudo apt-get install php5.6-gd

then restart your apache server by this command.

然后通过此命令重新启动您的 apache 服务器。

 sudo service apache2 restart

回答by Eugen Mihailescu

In CentOS (but the same may apply to other distros too) if you install the php7x-gd module followed by Apache restart and still the php -idoes not show the GD Support => enabledit might mean that the php.ini was not automatically configured to support this extension.

在 CentOS(但同样适用于其他发行版)中,如果您安装了 php7x-gd 模块,然后 Apache 重新启动,但仍然php -i没有显示GD Support => enabled这可能意味着 php.ini 没有自动配置为支持此扩展。

All you have to to is either to edit the /etc/php/php.inior to create a /etc/php.d/gd.inifile with the following content:

您所要做的就是编辑/etc/php/php.ini或创建/etc/php.d/gd.ini具有以下内容的文件:

[gd]
extension=/path/to/gd.so # use the gd.so absolute path here