如何在 Ubuntu 中安装 PHP GD

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/44718896/
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-26 03:01:31  来源:igfitidea点击:

How to install PHP GD in Ubuntu

phpubuntu

提问by Abdul Moeed Chohan

I want to convert the image in low resolution with GD. I'm working on IBM Server under these speces Version: PHP 7.0.15-0ubuntu0.16.04.4 (cli) ( NTS )
and I have also comment out the extension from php.ini but can't enabled the GD on php server. I Just received this error.

我想用 GD 转换低分辨率的图像。我正在 IBM Server 下使用这些规范版本:PHP 7.0.15-0ubuntu0.16.04.4 (cli) ( NTS )
我也注释掉了 php.ini 的扩展名,但无法在 php 服务器上启用 GD . 我刚收到这个错误。

Run Command:sudo apt-get install libgd

运行命令:sudo apt-get install libgd

Reading package lists... Done

阅读包裹清单...完成

Building dependency tree Reading state information... Done E: Unable to locate package libgd

构建依赖树读取状态信息...完成 E: 无法定位包 libgd

Second Command When I run give this message:

第二个命令当我运行时给出以下消息:

1) packages have unmet dependencies

1) 包有未满足的依赖项

and after running this command received this:

并在运行此命令后收到此:

Command:sudo apt-get install libgd-dev

命令:sudo apt-get install libgd-dev

Reading package lists... Done

阅读包裹清单...完成

Building dependency tree

构建依赖树

Reading state information... Done

读取状态信息...完成

You might want to run 'apt-get -f install' to correct these:

您可能需要运行 'apt-get -f install' 来更正这些:

The following packages have unmet dependencies: libgd-dev : Depends: libgd3 (= 2.1.1-4ubuntu0.16.04.6) but it is not going to be installed

以下软件包具有未满足的依赖项: libgd-dev : Depends: libgd3 (= 2.1.1-4ubuntu0.16.04.6) 但它不会被安装

         Depends: libpng-dev

         Depends: libz-dev

         Depends: libjpeg-dev

         Depends: libfreetype6-dev but it is not going to be installed

         Depends: libxpm-dev but it is not going to be installed

         Depends: libx11-dev but it is not going to be installed

         Depends: libxt-dev but it is not going to be installed

         Depends: libfontconfig-dev

         Depends: libvpx-dev but it is not going to be installed

         Depends: libtiff-dev

linux-image-virtual : Depends: linux-image-4.4.0-81-generic but it is not going to be installed

linux-image-virtual : 取决于: linux-image-4.4.0-81-generic 但它不会被安装

E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

E:未满足的依赖项。尝试不带软件包的“apt-get -f install”(或指定解决方案)。

Cause of this Problem:

此问题的原因:

PHP Fatal error: Uncaught Error: Call to undefined function imagecreatefromstring()

PHP 致命错误:未捕获的错误:调用未定义的函数 imagecreatefromstring()

Note please anyone tell me the step-by-step command to enable this GD Library on my this Linus machine. thanks alot

请注意,请任何人告诉我在我的这台 Linus 机器上启用此 GD 库的分步命令。多谢

回答by Andrei Todorut

sudo apt-get update

For 5.6 PHP

对于 5.6 PHP

sudo apt-get install php5.6-gd

For 7.0 PHP

对于 7.0 PHP

sudo apt-get install php7.0-gd