Skip to main content

How To Upgrade to PHP 7 on Ubuntu 14.04

Introduction

PHP 7, which was released on December 3, 2015, promises substantial speed improvements over previous versions of the language, along with new features like scalar type hinting. This guide explains how to quickly upgrade an Apache or Nginx web server running PHP 5.x (any release) to PHP 7.
Warning: As with most major-version language releases, it's best to wait a little while before switching to PHP 7 in production. In the meanwhile, it's a good time to test your applications for compatibility with the new release, perform benchmarks, and familiarize yourself with new language features.
If you're running any services or applications with active users, it is safest to first test this process in a staging environment.

Prerequisites

This guide assumes that you are running PHP 5.x on an Ubuntu 14.04 machine, using either mod_php in conjunction with Apache, or PHP-FPM in conjunction with Nginx. It also assumes that you have a non-root user configured with sudo privileges for administrative tasks.

Adding a PPA for PHP 7.0 Packages

A Personal Package Archive, or PPA, is an Apt repository hosted on Launchpad. PPAs allow third-party developers to build and distribute packages for Ubuntu outside of the official channels. They're often useful sources of beta software, modified builds, and backports to older releases of the operating system.
Ondřej Surý maintains the PHP packages for Debian, and offers a PPA for PHP 7.0 on Ubuntu. Before doing anything else, log in to your system, and add Ondřej's PPA to the system's Apt sources:
  • sudo add-apt-repository ppa:ondrej/php
You'll see a description of the PPA, followed by a prompt to continue. Press Enter to proceed.
Note: If your system's locale is set to anything other than UTF-8, adding the PPA may fail due to a bug handling characters in the author's name. As a workaround, you can install language-pack-en-base to make sure that locales are generated, and override system-wide locale settings while adding the PPA:

  • sudo apt-get install -y language-pack-en-base
  • sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
Once the PPA is installed, update the local package cache to include its contents:
  • sudo apt-get update
Now that we have access to packages for PHP 7.0, we can replace the existing PHP installation.

Upgrading mod_php with Apache

This section describes the upgrade process for a system using Apache as the web server and mod_php to execute PHP code. If, instead, you are running Nginx and PHP-FPM, skip ahead to the next section.
First, install the new packages. This will upgrade all of the important PHP packages, with the exception of php5-mysql, which will be removed.
  • sudo apt-get install php7.0
Note: If you have made substantial modifications to any configuration files in /etc/php5/, those files are still in place, and can be referenced. Configuration files for PHP 7.0 now live in /etc/php/7.0.
If you are using MySQL, make sure to re-add the updated PHP MySQL bindings:
  • sudo apt-get install php7.0-mysql 

Step you need do:

    • sudo add-apt-repository ppa:ondrej/php 
    • sudo apt-get install -y language-pack-en-base 
    • sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php 
    • sudo apt-get update
    • sudo apt-get install php7.0 
    • sudo apt-get install php7.0-mysql
    • php -v 
     
     

    Comments

    Popular posts from this blog

    The requested URL /phpmyadmin was not found on this server. Apache/2.4.18 (Ubuntu) Server at localhost Port 80

    Hi dudes, I'm getting Not Found error, when i hit a  http://localhost/phpmyadmin/ url, but i my system php, mysql & apache2 is already installed still i'm getting this error When i do this following step, the error get fixed. Do the following steps & Enjoy😃😄😅😄😄😃 You need to configure your apache2.conf to make phpMyAdmin work. For more detail Please read  this section  in Ubuntu wiki. open a termianl and run gksu gedit /etc/apache2/apache2.conf Then add the following line to the end of the file. Include /etc/phpmyadmin/apache.conf Then restart apache /etc/init.d/apache2 restart

    Install a node & npm specific versions using nvm (Node Version Manager)

    Hi buddies, When i tried to install a node & npm in my system, i will be facing some problem with the version. I want to install a recent LTS (Long Term Support) Don't Do (If you want to install a specific version):  I don't know, how its gonna installed, but its not a recent Node LTS version sudo apt-get install nodejs-legacy sudo apt-get install npm Do (Using a NVM- Node Version Manager to install a specific version): Use the following command to install a NVM into your system $ curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash Reload the system environment using this command $ source ~/.profile $ source ~/.bashrc List all the nodejs version using this command $ nvm ls-remote Install a nodejs version, what ever you want (If you want to install multiple node version you can install using this command) $ nvm install 6.11.1 $ nvm install 8.2.1 List a node version using this command

    PHP 7 with Laravel 5.3 installation problem ( Your requirements could not be resolved to an installable set of packages )

    I'm Facing this problem, while installation using laravel 5.3 with PHP 7 Your requirements could not be resolved to an installable set of packages.   Problem 1     - phpunit/phpunit 5.5.5 requires ext-dom * -> the requested PHP extension dom is missing from your system.     - phpunit/phpunit 5.5.4 requires ext-dom * -> the requested PHP extension dom is missing from your system.     - phpunit/phpunit 5.5.3 requires ext-dom * -> the requested PHP extension dom is missing from your system.     - phpunit/phpunit 5.5.2 requires ext-dom * -> the requested PHP extension dom is missing from your system.     - phpunit/phpunit 5.5.1 requires ext-dom * -> the requested PHP extension dom is missing from your system.     - phpunit/phpunit 5.5.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.     - phpunit/phpunit 5.4.8 requires ext-dom * -> the requested PHP extension dom is missing from your system.     - phpunit/phpunit 5.4.7 requir