When I try to install PHP7 form this command:

sudo apt-get install php7.0 libapache2-mod-php7.0 php7.0-mysql php7.0-cgi

Then I get error:

couldn't find or unable to locate all these packages.

So I want to download php7.1 from php.net, then run with Apache. What is the process to do that? How to configure files like apache2.conf & php.ini to run PHP?

  • 2
    ubuntu version? – 13dimitar Jan 19 '17 at 12:56
  • @Dimitar actually i am using LinuxMint 17.2, Ubuntu 14.04 – leecarter Jan 19 '17 at 12:57
  • Sorry but we do not support Mint, official Ubuntu only. Please ask at unix.stackexchange.com – Mark Kirby Jan 19 '17 at 14:53

You need to add additional repository, as php7 is not available for your distro version. Please make sure to clean all php packages and dependencies you have installed. Then proceed with:

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.0
  • Thanks but i want manually like download folder than run – leecarter Jan 19 '17 at 13:02
  • 2
    @leecarter Ehm, why would anyone bother to do so while having APT? – Melebius Jan 19 '17 at 14:14
  • Doesn't seem to be working anymore, I'm getting: Cannot add PPA: 'ppa:ondrej/php'. Please check that the PPA name or format is correct. – Piyin Jun 27 '17 at 21:20

Type the following command:

sudo apt-get install -y language-pack-en-base 
sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php


sudo add-apt-repository ppa:ondrej/php

Update the package index. To resynchronize the package index files from their sources, enter:

sudo apt-get update

List all PHP 7 packages

Type the following apt-cache command:

apt-cache search php7

Install PHP 7

Type the following command to install PHP 7 along with useful php modules such as MySQL, GD, curl and so on:

sudo apt-get install php7.0


sudo apt-get install php7.0 php7.0-cli php7.0-fpm php7.0-gd \
   php7.0-json php7.0-mysql php7.0-readline

Not the answer you're looking for? Browse other questions tagged or ask your own question.