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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36788873/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 00:56:30  来源:igfitidea点击:

Package php5 have no installation candidate (Ubuntu 16.04)

phpubuntuaptdpkgubuntu-16.04

提问by Srijan Karki

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

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

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

在我将 15.10 Ubuntu 更新到 16.04 后遇到了所有这些错误

回答by Rodrigo Stadler

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

Ubuntu 16.04 以 PHP7 为标准,所以没有 PHP5 包

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

但是,如果您愿意,您可以添加 PPA 以获取这些软件包:

Remove all the stock php packages

删除所有库存 php 包

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 :

列出已安装的 php 软件包,dpkg -l | grep php| awk '{print $2}' |tr "\n" " "然后使用 sudo aptitude purge your_packages_here 删除不需要的软件包,或者如果您想直接删除它们,请使用:

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

Add the PPA

添加 PPA

sudo add-apt-repository ppa:ondrej/php

Install your PHP Version

安装您的 PHP 版本

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

You can install php5.6 modules too ..

你也可以安装php5.6模块..

Verify your version

验证您的版本

sudo php -v

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

基于https://askubuntu.com/a/756186/532957(感谢@AhmedJerbi)

回答by Dong Nguyen

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

您必须使用前缀“php5.6-”而不是像 ubuntu 14.04 及更早版本中的“php5-”:

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

回答by Joe zhou

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

如果你只想安装 PHP,不管它是什么版本,试试 PHP7

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

回答by Ericky

sudo apt-get install php7.0-mysql

for php7.0 works well for me

对于 php7.0 对我来说效果很好

回答by xereon

This worked for me.

这对我有用。

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

;)

;)

回答by Leanne

I recently had this issue as well and solved it using the following command:

我最近也遇到了这个问题,并使用以下命令解决了它:

sudo apt install php7.2-cli

php is now installed. I'm using Ubuntu 18.04.

php现在已经安装好了。我正在使用 Ubuntu 18.04。

回答by MD Shahrouq

Currently, I am using Ubuntu 16.04 LTS. Me too was facing same problem while Fetching the Postgress Database values using Php so i resolved it by using the below commands.

目前,我使用的是 Ubuntu 16.04 LTS。我在使用 Php 获取 Postgress 数据库值时也面临同样的问题,所以我使用以下命令解决了它。

Mine PHP version is 7.0, so i tried the below command.

我的 PHP 版本是 7.0,所以我尝试了下面的命令。

apt-get install php-pgsql

Remember to restart Apache.

apt-get install php-pgsql

记得重启 Apache

/etc/init.d/apache2 restart