php - 包php5没有安装候选(Ubuntu 16.04)

当我尝试使用以下代码在Ubuntu 16.04中安装php5时:

sudo apt-get install php5 php5-mcrypt

我得到以下错误:
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

我试过重新安装,但没用。
所有这些错误都是在我将15.10 Ubuntu更新到16.04之后遇到的。


最佳答案:

Ubuntu 16.04以php7为标准,因此没有php5包
但是,如果您愿意,您可以添加一个购电协议,以任何方式获得这些包:
删除所有常用的PHP包
使用dpkg -l | grep php| awk '{print $2}' |tr "\n" " "列出已安装的PHP包,然后使用sudo-aptitude删除不需要的包。在此处清除您的\包,或者如果要直接删除它们,请使用:

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

添加PPA
sudo add-apt-repository ppa:ondrej/php

安装PHP版本
sudo apt-get update
sudo apt-get install php5.6

您也可以安装php5.6模块。
验证您的版本
sudo php -v

基于(谢谢@ahmedjerbi)