13
root@areeb-Inspiron-3420:/var/www/html# apt install php5
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package php5 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'php5' has no installation candidate
root@areeb-Inspiron-3420:/var/www/html# apt-get install libapache2-mod-php5
Reading package lists... Done
Building dependency tree... 50%
Building dependency tree       
Reading state information... Done
Package libapache2-mod-php5 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'libapache2-mod-php5' has no installation candidate

What should I do now?

TRiG
  • 1,910

2 Answers2

22

Ubuntu 16.04 LTS comes with PHP 7.0. To install it, you need to run:

sudo apt-get install php

Or rather pick a specific PHP Web SAPI, most probably you need support for Apache2:

sudo apt-get install libapache2-mod-php php

Or PHP FPM

sudo apt-get install php-fpm php

If you specifically need PHP 5.x, you'll need to use ppa:ondrej/php and install, f.e. PHP 5.6 for Apache2:

sudo apt-get install php5.6 libapache2-mod-php5.6
Vlad
  • 103
  • 4
oerdnj
  • 7,940
  • 1
    Sorry but in pure Ubuntu 16.04 LTS apt-get install php gives back Unable to locate package php. So frustrating! – Sliq Aug 07 '16 at 03:25
  • 1
    @Sliq It must be your local configuration error since php package is available in Xenial: http://packages.ubuntu.com/search?keywords=php – oerdnj Aug 07 '16 at 06:12
  • Thanks, I think the packages on Vagrant box are broken or so (as it's the most official boxavailable) :( – Sliq Aug 07 '16 at 16:37
1

16.04 does not have PHP 5 in the official repositories. Install a 14.04 system, or use this PPA.

fkraiem
  • 12,555
  • 4
  • 35
  • 40
  • Oddly enough, once I got it PHP5+apache set up through that PPA, I was able to ppa-purge -o ppa:ondrej/php and I still have php5... and I can use Imagemagick and other things the normal Ubuntu PHP5 packages have. – NoBugs Jul 12 '16 at 01:47
  • @NoBugs I'd be curious to see where those PHP 5 packages are coming from; could you please pastebin the output of apt list --installed | grep php? – fkraiem Jul 12 '16 at 02:04
  • Ok looks like either they just removed, or just added them: https://www.google.com/search?client=ubuntu&channel=fs&q=php5.6+site%3Apackages.ubuntu.com&ie=utf-8&oe=utf-8#channel=fs&q=xenial+php5.6+site:packages.ubuntu.com – NoBugs Jul 12 '16 at 03:53
  • Yes, there were PHP 5 packages in Xenial when it was still in development, but they were removed some time before the release. – fkraiem Jul 12 '16 at 03:55
  • Why would they have removed them? – NoBugs Jul 12 '16 at 04:22
  • 1
    Mostly because they didn't want to release (and have to support) both, see https://bugs.launchpad.net/ubuntu/+source/php5/+bug/1522422 – fkraiem Jul 12 '16 at 04:29