Ubuntu
如何在 php 中安裝 GD 庫?
當我嘗試在 PHP 中使用 imagefromjpeg() 函式時,它拋出了錯誤。所以,我嘗試使用以下命令安裝 GD 庫:
sudo apt-get install php5-gd
但我收到以下錯誤。
php5-gd : Depends: php5-common (= 5.5.9+dfsg-1ubuntu4) but 5.5.10+dfsg-1+deb.sury.org~saucy+1 is to be installed E: Unable to correct problems, you have held broken packages.
我正在使用 Ubuntu 14.04LTS。我最近從 ubuntu 13.10 升級了我的作業系統。如何克服這個錯誤?
的輸出
dpkg -l|grep php
是:ii cakephp 1.3.15-1 all MVC rapid application development framework for PHP ii cakephp-scripts 1.3.15-1 all MVC rapid application development framework for PHP (scripts) ii libapache2-mod-php5 5.5.10+dfsg-1+deb.sury.org~saucy+1 amd64 server-side, HTML-embedded scripting language (Apache 2 module) ii libedit2:amd64 3.1-20130712-2+debphp.org~saucy+3 amd64 BSD editline and history libraries ii libjson-c2:amd64 0.11-3+debphp.org~saucy+1 amd64 JSON manipulation library - shared library ii libjson-c2:i386 0.11-3+debphp.org~saucy+1 i386 JSON manipulation library - shared library ii libjson0:amd64 0.11-3+debphp.org~saucy+1 amd64 JSON manipulation library (transitional package) ii php-gettext 1.0.11-1 all read gettext MO files directly, without requiring anything other than PHP ii php-pear 5.5.10+dfsg-1+deb.sury.org~saucy+1 all PEAR - PHP Extension and Application Repository ii php5 5.5.10+dfsg-1+deb.sury.org~saucy+1 all server-side, HTML-embedded scripting language (metapackage) ii php5-cgi 5.5.10+dfsg-1+deb.sury.org~saucy+1 amd64 server-side, HTML-embedded scripting language (CGI binary) ii php5-cli 5.5.10+dfsg-1+deb.sury.org~saucy+1 amd64 command-line interpreter for the php5 scripting language ii php5-common 5.5.10+dfsg-1+deb.sury.org~saucy+1 amd64 Common files for packages built from the php5 source ii php5-curl 5.5.10+dfsg-1+deb.sury.org~saucy+1 amd64 CURL module for php5 ii php5-dev 5.5.10+dfsg-1+deb.sury.org~saucy+1 amd64 Files for PHP5 module development rc php5-gd 5.4.9-4ubuntu2.4 amd64 GD module for php5 ii php5-imagick 3.1.2-1+debphp.org~saucy+1 amd64 ImageMagick module for php5 ii php5-json 1.3.2-3+debphp.org~saucy+1 amd64 JSON module for php5 ii php5-mcrypt 5.5.10+dfsg-1+deb.sury.org~saucy+1 amd64 MCrypt module for php5 rc php5-mysql 5.4.9-4ubuntu2.4 amd64 MySQL module for php5 ii php5-mysqlnd 5.5.10+dfsg-1+deb.sury.org~saucy+1 amd64 MySQL module for php5 (Native Driver) ii php5-pgsql 5.5.10+dfsg-1+deb.sury.org~saucy+1 amd64 PostgreSQL module for php5 ii php5-readline 5.5.10+dfsg-1+deb.sury.org~saucy+1 amd64 Readline module for php5 ii php5-xdebug 2.2.3-2build1 amd64 Xdebug Module for PHP 5 ii phpmyadmin 4:4.0.10-1 all MySQL web administration tool ii pkg-php-tools 1.11 all various packaging tools and scripts for PHP packages
看來您已經通過啟動板 PPA 安裝了 PHP:
https://launchpad.net/~ondrej/+archive/php5
如果 ppa 仍處於活動狀態,請檢查您的 apt sources.list。在 14.04 上,您應該啟動這些儲存庫:
deb http://ppa.launchpad.net/ondrej/php5/ubuntu trusty main deb-src http://ppa.launchpad.net/ondrej/php5/ubuntu trusty main
解釋:
似乎您之前添加了額外的 PHP-launchpad 儲存庫,但在 dist-upgrade 期間它被停用了。因此,apt 嘗試
php5-gd
從標準 debian 儲存庫安裝,但此版本還需要標準 php-common 作為依賴項(您沒有)。通過再次啟動啟動板儲存庫,php5-gd
已從那里安裝,並且您的所有其他 php 包應該已從 ppa 升級到 Ubuntu 14.04(“信任”)版本。