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?

0

2 Answers 2

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
3
  • 1
    Sorry but in pure Ubuntu 16.04 LTS apt-get install php gives back Unable to locate package php. So frustrating!
    – Sliq
    Aug 7, 2016 at 3:25
  • 1
    @Sliq It must be your local configuration error since php package is available in Xenial: packages.ubuntu.com/search?keywords=php
    – oerdnj
    Aug 7, 2016 at 6:12
  • Thanks, I think the packages on Vagrant box are broken or so (as it's the most official boxavailable) :(
    – Sliq
    Aug 7, 2016 at 16:37
1

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

6
  • 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, 2016 at 1: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, 2016 at 2:04
  • Ok looks like either they just removed, or just added them: google.com/…
    – NoBugs
    Jul 12, 2016 at 3: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, 2016 at 3:55
  • 1
    Mostly because they didn't want to release (and have to support) both, see bugs.launchpad.net/ubuntu/+source/php5/+bug/1522422
    – fkraiem
    Jul 12, 2016 at 4:29

Not the answer you're looking for? Browse other questions tagged .