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

时间:2022-01-22 23:40:53

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之后遇到的

6 个解决方案

#1


117  

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 '{$2}' |tr "\n" "),然后用sudo aptitude清除你的_packages_here或如果你想直接删除它们全部使用:

sudo aptitude purge `dpkg -l | grep php| awk '{print $2}' |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)

#2


45  

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

你必须使用前缀“php5.6-”而不是“php5-”,如ubuntu 14.04和olders:

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

#3


30  

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

#4


2  

sudo apt-get install php7.0-mysql

for php7.0 works well for me

php7.0对我来说很好用

#5


0  

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获取后台数据库值时也遇到了同样的问题,因此我使用下面的命令解决了这个问题。

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

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

apt-get install php-pgsql

Remember to restart Apache.

记得重新启动Apache。

/etc/init.d/apache2 restart

#6


0  

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。

#1


117  

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 '{$2}' |tr "\n" "),然后用sudo aptitude清除你的_packages_here或如果你想直接删除它们全部使用:

sudo aptitude purge `dpkg -l | grep php| awk '{print $2}' |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)

#2


45  

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

你必须使用前缀“php5.6-”而不是“php5-”,如ubuntu 14.04和olders:

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

#3


30  

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

#4


2  

sudo apt-get install php7.0-mysql

for php7.0 works well for me

php7.0对我来说很好用

#5


0  

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获取后台数据库值时也遇到了同样的问题,因此我使用下面的命令解决了这个问题。

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

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

apt-get install php-pgsql

Remember to restart Apache.

记得重新启动Apache。

/etc/init.d/apache2 restart

#6


0  

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。

相关文章