[php] Package php5 have no installation candidate (Ubuntu 16.04)

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

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

This question is related to php ubuntu apt dpkg ubuntu-16.04

The answer is


sudo apt-get install php7.0-mysql

for php7.0 works well for me


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

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

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.

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

apt-get install php-pgsql

Remember to restart Apache.

/etc/init.d/apache2 restart

This worked for me.

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

;)


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

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

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.


Examples related to php

I am receiving warning in Facebook Application using PHP SDK Pass PDO prepared statement to variables Parse error: syntax error, unexpected [ Preg_match backtrack error Removing "http://" from a string How do I hide the PHP explode delimiter from submitted form results? Problems with installation of Google App Engine SDK for php in OS X Laravel 4 with Sentry 2 add user to a group on Registration php & mysql query not echoing in html with tags? How do I show a message in the foreach loop?

Examples related to ubuntu

grep's at sign caught as whitespace "E: Unable to locate package python-pip" on Ubuntu 18.04 How to Install pip for python 3.7 on Ubuntu 18? "Repository does not have a release file" error ping: google.com: Temporary failure in name resolution How to install JDK 11 under Ubuntu? How to upgrade Python version to 3.7? Issue in installing php7.2-mcrypt Install Qt on Ubuntu Failed to start mongod.service: Unit mongod.service not found

Examples related to apt

E: Unable to locate package npm How to update-alternatives to Python 3 without breaking apt? Package php5 have no installation candidate (Ubuntu 16.04) Amazon Linux: apt-get: command not found How do you run `apt-get` in a dockerfile behind a proxy? What is the difference/usage of homebrew, macports or other package installation tools? How to check the version before installing a package using apt-get? How to install "make" in ubuntu? Installing SciPy and NumPy using pip How can I get a list of repositories 'apt-get' is checking?

Examples related to dpkg

Package php5 have no installation candidate (Ubuntu 16.04) How to check the version before installing a package using apt-get?

Examples related to ubuntu-16.04

Yarn: How to upgrade yarn version using terminal? pull access denied repository does not exist or may require docker login Failed to start mongod.service: Unit mongod.service not found How to completely uninstall python 2.7.13 on Ubuntu 16.04 Anaconda-Navigator - Ubuntu16.04 Default password of mysql in ubuntu server 16.04 Unable to set default python version to python3 in ubuntu "pip install json" fails on Ubuntu Unable to start the mysql server in ubuntu How to install php-curl in Ubuntu 16.04