12

when I tried to use imagefromjpeg() function in PHP,it throwed error.So, I tried to install GD library using the following command:

sudo apt-get install php5-gd

But I got the following error.

 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.

I am using Ubuntu 14.04LTS. I recently upgraded my OS from ubuntu 13.10. How to overcome this error?

The output of dpkg -l|grep php is :

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
Ganesh Babu
  • 223
  • 1
  • 2
  • 6

2 Answers2

5

It seems you have installed PHP via launchpad PPA:

https://launchpad.net/~ondrej/+archive/php5

Check your apt sources.list if the ppa is still active. On 14.04, you should have these repos active:

deb http://ppa.launchpad.net/ondrej/php5/ubuntu trusty main 
deb-src http://ppa.launchpad.net/ondrej/php5/ubuntu trusty main 

Explanation:

It seems you had the additional PHP-launchpad repository added before, but it was deactivated during dist-upgrade. Because of that, apt tried to install php5-gd from the standard debian repo, but this version also needs a standard php-common as dependency (which you don't have). By activating the launchpad repo again, php5-gd has been installed from there and all your other php packages should have been upgraded to the Ubuntu 14.04 ("trusty") versions from the ppa.

etagenklo
  • 5,694
  • 1
  • 25
  • 31
  • I still cannot check your command. I get the following error : deb: command not found. I tried using sudo apt-get install deb.But still not use – Ganesh Babu May 21 '14 at 11:05
  • 1
    You should not enter this in the shell, you should check the files in `/etc/apt/sources.list` and `/etc/apt/sources.list.d/` for these entries and add them if neccessary. – etagenklo May 21 '14 at 11:26
  • I've added those lines in the file you've specified. But still I didn't find it working – Ganesh Babu May 21 '14 at 11:41
  • Did you issue `sudo apt-get update` before trying it again? – etagenklo May 21 '14 at 13:38
  • Thank you very much. Your solution clearly worked out for me. But still I can't understand what has happened. Have I upgraded my PHP or Have I reinstalled my PHP? – Ganesh Babu May 21 '14 at 15:09
  • 1
    I've updated my answer with an explanation. – etagenklo May 23 '14 at 07:43
  • Response from Etagenklo should be valid, though in my case after adding the PPA's it not only installed php5-gd and php5 common, but it also installed a lot more of extensions. Though it was expected it also try to install new available php.ini's. Take this into serious consideration: If you run this into production server and you have your own edits on ini files you should always want to preserve the installed ones. Overwrite the original may lead your website goes down. – Jaziel Lopez Jun 12 '15 at 18:40
0

I know its been a while for the original answer. I got this installed on Ubuntu Server 14.04 LTS by first installing sudo apt-get install php7.0-fpm then running sudo apt-get install php7.0-gd. Confirmed that it works great, especially for captcha generation that is my use case for an all-php solution. There is no reason not to upgrade from php5x at this point as 7x has many benefits and no downsides at this point in 2017.

james-see
  • 249
  • 2
  • 5