Package php5 have no installation candidate (Ubuntu 16.04)

316,932

Solution 1

Ubuntu 16.04 comes with PHP7 as the standard, so there are no PHP5 packages

However if you like you can add a PPA to get those packages anyways:

Remove all the stock php packages

List installed php packages with dpkg -l | grep php| awk '{print $2}' |tr "\n" " " then remove unneeded packages with sudo aptitude purge your_packages_here or if you want to directly remove them all use :

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

Add the PPA

sudo add-apt-repository ppa:ondrej/php

Install your PHP Version

sudo apt-get update
sudo apt-get install php5.6

You can install php5.6 modules too ..

Verify your version

sudo php -v

Based on https://askubuntu.com/a/756186/532957 (thanks @AhmedJerbi)

Solution 2

You must use prefix "php5.6-" instead of "php5-" as in ubuntu 14.04 and olders:

sudo apt-get install php5.6 php5.6-mcrypt

Solution 3

If you just want to install PHP no matter what version it is, try PHP7

sudo apt-get install php7.0 php7.0-mcrypt

Solution 4

sudo apt-get install php7.0-mysql

for php7.0 works well for me

Solution 5

This worked for me.

sudo apt-get update
sudo apt-get install lamp-server^ -y

;)

Share:
316,932
Srijan Karki
Author by

Srijan Karki

Currently learning: Python, Android, Java, Laravel, JavaScript, JQuery and MySQL.

Updated on October 03, 2020

Comments

  • Srijan Karki
    Srijan Karki over 3 years

    When i try to install php5 in Ubuntu 16.04 by using following code:

    sudo apt-get install php5 php5-mcrypt
    

    I get following 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
    

    I have tried reinstalling but it does not help.

    All this error was encountered after I updated my 15.10 Ubuntu to 16.04

  • Srijan Karki
    Srijan Karki about 8 years
    i understand that, but is there any way to make this work in php7 itself?
  • Chris Stadler
    Chris Stadler about 8 years
    @SrijanKarki you can just use sudo apt-get install php7 to install php7, however I don't get what you mean with "a way to make this work in php7". your question was about installing php5, no? otherwise clarify and I'll edit my answer accordingly
  • Srijan Karki
    Srijan Karki about 8 years
    ya i installed php7 already. And i also tried doing as said in this link. Here. However, localhost/phpadmin page cannot be found. Is there some things that may be causing this error?
  • Quentin
    Quentin about 8 years
    @SrijanKarki — So install PHP Admin. It has nothing to do with PHP other than being written in the language.
  • Savara
    Savara over 7 years
    This has just rescued me from so much pain and frustration!
  • Kamaldeep Singh
    Kamaldeep Singh over 7 years
    use prefix "php5.6-" instead of "php5-" as on ubuntu 16.04 as well
  • Jekis
    Jekis over 7 years
    Doesn't work for me. 0 upgraded, 0 newly installed
  • Sambruce Sam
    Sambruce Sam over 6 years
    Works like a charm. You'll need to install aptitute . Run this to install aptitute: sudo apt-get install aptitude
  • WebBrother
    WebBrother about 5 years
    E: Package 'php7.0-mysql' has no installation candidate