Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Package php5 have no installation candidate (Ubuntu 16.04)

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

like image 534
Srijan Karki Avatar asked Apr 22 '16 08:04

Srijan Karki


5 Answers

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)

like image 178
Chris Stadler Avatar answered Oct 02 '22 10:10

Chris Stadler


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
like image 37
Dong Nguyen Avatar answered Oct 02 '22 11:10

Dong Nguyen


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

sudo apt-get install php7.0 php7.0-mcrypt
like image 27
Joe zhou Avatar answered Oct 02 '22 10:10

Joe zhou


sudo apt-get install php7.0-mysql

for php7.0 works well for me

like image 32
Ericky Avatar answered Oct 02 '22 12:10

Ericky


This worked for me.

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

;)

like image 39
xereon Avatar answered Oct 02 '22 11:10

xereon