2

I tried to use this command to install php in Ubuntu 16.04:

sudo apt-get install php5 libapache2-mod-php5

But it shows:

'php5' has no installation candidate

How can I install it?

5
  • to run just $ php /find/location/file to install on ubuntu 6 i think php 7 will installed Commented Apr 5, 2018 at 20:07
  • maybe u wanna read this https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu Commented Apr 5, 2018 at 20:08
  • your provided link is not reach 404 error Commented Apr 5, 2018 at 20:10
  • 1
    Ubuntu 16.04 comes with PHP 7.0. If you want to install version 5, you'll have to find a third party source or compile from source. Commented Apr 5, 2018 at 20:14
  • 1
    You might get better help at AskUbuntu. There are already posts there related to this topic, like this: askubuntu.com/questions/756879/… Commented Apr 5, 2018 at 23:44

1 Answer 1

9

Ubuntu 16.04 comes with PHP7, so there are no PHP5 packages.

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

Remove all the stock php packages

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 :

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

Add the PPA

sudo add-apt-repository ppa:ondrej/php 

Install your PHP Version

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

You can install php5.6 packages.

Then, verify your PHP version

sudo php -v 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.