2

I have upgraded my system to ubuntu 16.04 LTS, now I have issue this newer version install PHP 7 and remove the PHP 5, How I can install PHP 5.4 on ubuntu 16.04 LTS?

I tried:

sudo apt-get install php5

and I got this error:

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
Muhammad Shahzad
  • 9,340
  • 21
  • 86
  • 130
  • 1
    First remove php7 package then try to update system.And then install php5.x – Web Artisan Apr 28 '16 at 09:41
  • 1
    if you want to run both versions (which i would advise) use something like [PHPBrew](http://123code.co.uk/view/Tutorials/using-phpbrew-to-switch-and-manage-php-versions) to manage them. – DevDonkey Apr 28 '16 at 09:42
  • `sudo php5enmod mcrypt` sudo: php5enmod: command not found, why this? – Muhammad Shahzad Apr 28 '16 at 10:21
  • 2
    Finally I kicked off ubuntu(16.04) and reinstall ubuntu 15.10. This is my sooper dooper solution. – Muhammad Shahzad May 02 '16 at 06:31
  • @MuhammadShahzad That is a very poor "solution"! Ubuntu 15.10 was not a LTS (Long-Term Support) release; it reached its end-of-life several months ago, and is no longer receiving any updates, even for security issues. –  Aug 23 '16 at 23:57
  • @duskwuff I have update some time ago my ubuntu version I was facing number of issues(this version has php 7 and I need php5), anyway I will try for latest version once again. – Muhammad Shahzad Aug 24 '16 at 05:17
  • 2
    Possible duplicate of [Package php5 have no installation candidate (Ubuntu 16.04)](http://stackoverflow.com/questions/36788873/package-php5-have-no-installation-candidate-ubuntu-16-04) – Alastair Irvine May 02 '17 at 14:41

1 Answers1

5

Ubuntu 16.04 comes with PHP7 ,there are no PHP5 packages. Remove all php7 packages:

sudo aptitude purge `dpkg -l | grep php| awk '{print $2}' |tr "\n" " "

New PPA

sudo add-apt-repository ppa:ondrej/php

Update packages:

sudo apt-get update

Install PHP:

sudo apt-get install php5.6

Check PHP Version:

php -v
Ejaz
  • 8,719
  • 3
  • 34
  • 49
Muhammad Shahzad
  • 9,340
  • 21
  • 86
  • 130