How to: Install PHP 7 on Ubuntu 14.04 / 16.04

How to: Install PHP 7 on Ubuntu 14.04 / 16.04


It’s release day! Or it was on the 3rd of December 2015 – the release date for the final version of PHP 7.0. There have been a whole host of improvements made to PHP but we won’t delve too deep into changes. This is a very quick guide on how to update to the latest release for those of you running a Ubuntu Linux system.

It is very simple, thanks to ondrej managing a ppa repo for this release, like many of the previous releases. All we need to do is add the ppa to our system, update the software sources and install our new version of PHP.

# Ubuntu 14.04 Only
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.0-cli php7.0-common libapache2-mod-php7.0 php7.0 php7.0-mysql php7.0-fpm

Other packages which might be useful include:

sudo apt-get install php-mcrypt php7.0-soap php7.0-mbstring php7.0-intl php7.0-xml php7.0-curl php7.0-gd

You should now be running the latest and greatest within the PHP world. The easiest way to test if it’s working for you is to run:

php -v

And it should look like:

PHP7 in the Terminal

Note: If you are also trying to install phpmyadmin, see more information here.

Edit 15/01/16: Moved to the ppa:ondrej/php repo instead of ppa:ondrej/php7.0 (because the two sets of packages can co-exist).

Do you think this is missing any modules? If so, let us know in the comments.

Photo by C. Evans

19 responses to “How to: Install PHP 7 on Ubuntu 14.04 / 16.04

  1. From all articles about PHP 7 installation only this one included libapache2-mod-php7.0. Good stuff, after that it actually started working.

    1. Yes, ohh yes! I couldn’t agree more. I accidentally broke an update to one site because it was using memcached and I didn’t realise (luckily wasn’t an important site).

  2. sudo apt-get install php7.0-gd

    Can someone check the above and also check to ensure the GD library is installed.

    I had to use the following:

    sudo apt-get install php5-gd
  3. Could you please update the article to point to ppa:ondrej/php, I will be deprecating php-7.0 as the co-installable repository is working
    just fine, so I am just building the same packages twice. I am trying to hunt down all the popular articles around, so I could kill the ppa:ondrej/php-7.0.



  4. I have clean lubuntu 14.04. Command sudo add-apt-repository ppa: ondrej / php help was change version from 5.0 to 5.5, this is not php 7. Ma be redact source list? What address in source list responsible for installing php 7?

Leave a Reply

Your email address will not be published. Required fields are marked *