简体   繁体   English

Ubuntu中如何安装PHP GD

[英]How to install PHP GD in Ubuntu

I want to convert the image in low resolution with GD.我想用 GD 以低分辨率转换图像。 I'm working on IBM Server under these speces Version: PHP 7.0.15-0ubuntu0.16.04.4 (cli) ( NTS )我在这些规格版本的 IBM 服务器上工作: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.我还注释掉了 php.ini 的扩展名,但无法在 php 服务器上启用 GD。 I Just received this error.我刚收到这个错误。

Run Command: sudo apt-get install libgd运行命令: sudo apt-get install libgd

Reading package lists... Done读取 package 列表...完成

Building dependency tree Reading state information... Done E: Unable to locate package libgd构建依赖树正在读取 state 信息...完成 E: 无法定位 package 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读取 package 列表...完成

Building dependency tree构建依赖树

Reading state information... Done读取state信息...完成

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: Depends: linux-image-4.4.0-81-generic 但它不会被安装

E: Unmet dependencies. E:未满足的依赖项。 Try 'apt-get -f install' with no packages (or specify a solution).尝试不带包的“apt-get -f install”(或指定解决方案)。

Cause of this Problem:这个问题的原因:

PHP Fatal error: Uncaught Error: Call to undefined function imagecreatefromstring() PHP 致命错误:未捕获错误:调用未定义 function imagecreatefromstring()

Note please anyone tell me the step-by-step command to enable this GD Library on my this Linus machine.请注意,请任何人告诉我在我的这台 Linus 机器上启用这个 GD 库的分步命令。 thanks alot多谢

keep it simple...把事情简单化...

apt-get install php-gd

will usually find the correct package and version for your install setup and just install everything nice for you.. did for me通常会为您的安装设置找到正确的 package 和版本,然后安装所有适合您的东西..为我做了

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

I had an issue where it still wasn't working, even after installing (on ubuntu 20.04):我遇到了一个问题,它仍然无法正常工作,即使在安装之后(在 ubuntu 20.04 上):

sudo apt-get install php-gd

What finally worked was when I remembered to restart my server, which in my case was:最终起作用的是当我记得重新启动我的服务器时,在我的例子中是:

sudo service apache2 restart

Hopefully this will help someone else.希望这会帮助别人。

I had similar issue but running sudo apt-get install php8.1-gd didn't solve the issue.我有类似的问题,但运行sudo apt-get install php8.1-gd并没有解决问题。 I had to run sudo apt-get install php8.1-gd/bullseye .我必须运行sudo apt-get install php8.1-gd/bullseye

If you running Debian 11,如果您运行 Debian 11,

sudo apt-get install php8.1-gd/bullseye

If you running Debian 10,如果你运行 Debian 10,

sudo apt-get install php8.1-gd/buster

If you are using other debian releases, just replace bullseye with your debian release name.如果您使用的是其他 debian 版本,只需将bullseye替换为您的 debian 版本名称即可。

You can also search for the extension in the terminal.您也可以在终端中搜索扩展名。 And install from the result.并从结果中安装。

sudo apt search php8.1-gd

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM