How to upgrade php 5.6 to 7.0 on Ubuntu 14.04 LTS

By Cris, November 13, 2016
Last updated: October 27, 2017
Edit

Upgrade your server’s php installation from 5.6.x to 7.0.x on Ubuntu 14.04 LTS

Continuing with the php upgrading series, this guide will show you how to bring your standard Ubuntu 14.04 LTS Server installation to 7.0.x. The 7-series PHP releases focus on speed. You can read about the latest new features.

Begin by adding ‘s newest (as of 2016) PPA repository and updating sources as follows:

Note: If you’ve followed the 5.5 to 5.6 upgrade guide, you already have the PPA added.

sudo LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
sudo apt-get update

Next we should list all existing php 5.6.x packages (so we know which equivalent version need to be loaded for 7.0.x):

Warning: This has been tested with Ubuntu 14.04 LTS and PHP 5.6.19 and might be valid for this release only! Use at your own risk!

Issue the following command:

dpkg --get-selections | grep php

This example gave the following output:

dpkg --get-selections | grep php

libapache2-mod-php5.6                           install
php-pear                                        install
php-xml-parser                                  install
php5.6                                          install
php5.6-cli                                      install
php5.6-common                                   install
php5.6-curl                                     install
php5.6-dba                                      install
php5.6-dev                                      install
php5.6-gd                                       install
php5.6-intl                                     install
php5.6-json                                     install
php5.6-ldap                                     install
php5.6-mbstring                                 install
php5.6-mcrypt                                   install
php5.6-mysql                                    install
php5.6-opcache                                  install
php5.6-pgsql                                    install
php5.6-readline                                 install
php5.6-soap                                     install
php5.6-sqlite3                                  install
php5.6-xml                                      install
php5.6-xsl                                      install
php5.6-zip                                      install
pkg-php-tools                                   install

Download the php7.0.x versions them like so:

sudo apt-get install php7.0 php7.0-cli php7.0-common php7.0-curl php7.0-dev php7.0-gd php7.0-intl php7.0-json php7.0-ldap php7.0-mbstring php7.0-mcrypt php7.0-memcache php7.0-memcached php7.0-mysql php7.0-pgsql php7.0-readline php7.0-sqlite php7.0-xml php7.0-xsl libzip4 php7.0-zip

Apt might also include a few additional packages, proceed (Y).

Next, disable the php5.6 apache2 module and load the php7.0 apache2 module in its place. End by restarting your apache2 server.

sudo a2dismod php5.6
sudo a2enmod php7.0
sudo service apache2 restart

All done 🙂

If you would like to support Ondřej Surý and his efforts, visit his donation page for a way to do so!

The official PHP Migration (5.6.x to 7.0.x) Notes can be found here. Additional migration details, change logs, new/ deprecated features for all other migrations are also present.

2 Comments

  1. jameel ahmed ansari says:

    Great Helped me to fix the issue . Thanks a lot

What do you think?

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.