当我尝试使用以下代码在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后遇到了所有这个错误
7 回答
如果您只想安装PHP,无论它是什么版本,请尝试PHP7
对于php7.0适合我
这对我有用 .
;)
目前,我使用的是Ubuntu 16.04 LTS . 在使用Php获取Postgress数据库值时,我也遇到了同样的问题,所以我使用以下命令解决了这个问题 .
我的PHP版本是7.0,所以我尝试了下面的命令 .
apt-get install php-pgsql
Remember to restart Apache .
我最近也有这个问题并使用以下命令解决了它:
php现已安装 . 我正在使用Ubuntu 18.04 .
Ubuntu 16.04标配PHP7,因此没有PHP5软件包
但是,如果您愿意,可以添加PPA来获取这些包:
Remove all the stock php packages
使用
dpkg -l | grep php| awk '{print $2}' |tr "\n" " "
列出已安装的php包,然后使用sudo aptitude清除your_packages_here删除不需要的包,或者如果要直接删除它们,请使用:Add the PPA
Install your PHP Version
你也可以安装php5.6模块..
Verify your version
基于https://askubuntu.com/a/756186/532957(感谢@AhmedJerbi)
您必须在ubuntu 14.04和olders中使用前缀“php5.6-”而不是“php5-”: