Php5 package has no install candidate (Ubuntu 16.04)

When I try to install php5 on Ubuntu 16.04 using the following code:

sudo apt-get install php5 php5-mcrypt 

I get the 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 tried to reinstall, but that does not help.

All this error occurred after updating my 15.10 Ubuntu to 16.04

+67
php ubuntu apt dpkg
Apr 22 '16 at 8:34
source share
5 answers

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

However, if you like, you can add PPA to receive these packages:

Remove all packages php package

List of installed php packages with dpkg -l | grep php| awk '{print $2}' |tr "\n" " " dpkg -l | grep php| awk '{print $2}' |tr "\n" " " dpkg -l | grep php| awk '{print $2}' |tr "\n" " " , then remove the unwanted packages with sudo aptitude purge your_packages_here or if you want to remove them all, use:

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

Add PPA

 sudo add-apt-repository ppa:ondrej/php 

Install PHP Version

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

You can also install php5.6 modules.

Check your version

 sudo php -v 

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

+107
Apr 22 '16 at 9:04 on
source share

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

 sudo apt-get install php5.6 php5.6-mcrypt 
+41
May 6 '16 at 3:33
source share

If you just want to install PHP regardless of its version, try PHP7

 sudo apt-get install php7.0 php7.0-mcrypt 
+28
May 19 '16 at PM
source share
 sudo apt-get install php7.0-mysql 

for php7.0 works well for me

+2
May 05 '17 at 1:46 a.m.
source share

I am currently using Ubuntu 16.04 LTS. I also had to deal with the same problem while fetching Postgress Database values ​​using Php, so I resolved it using the commands below.

My version of PHP is 7.0, so I tried the command below.

apt-get install php-pgsql

Remember to restart Apache .

 /etc/init.d/apache2 restart 
0
Feb 16 '17 at 15:47
source share



All Articles