Easy Steps to Upgrade PHP 5.5/5.6 To PHP 7

Upgrade PHP 5.5/5.6 To PHP 7

In this article, I am going to demonstrate you how to upgrade php 5.5 to php 7. Also covering the topic of Operating system up gradation.

Overview

Basically, this article is based on a scenario where you have Lower OS version with the lower version of PHP.

In this case, what happened when you trying to upgrade PHP from lower version to higher version. You find the operating system would not be supporting the latest libraries. It will give the library conflict error or dependency errors.

To overcome all this kind of errors and to upgrade PHP to a higher version. You will have no other option than upgrading Operating System for smooth upgradations of PHP.

I have faced the same issue when one of our projects need the PHP 7. We had operating system Debian wheezy 6 and PHP 5.5. I was trying to install PHP 7 on Debian 6 but had lots of errors and waste lot’s of time on the simple issue.

After researching on the internet I had come to know that I have to upgrade the OS first then upgrade PHP version.

This article is to explain you the complete steps to upgrade OS and upgrade php. Before starting with upgradations process takes backup of your data.

Note: If you already have the latest operating system installed then skip the upgradations process of OS and directly follow below steps to upgrade php version.

First start with upgradations of Debian Wheezy 6 to Debian Jessie 8. Now one question comes to your mind why I upgrade os from wheezy to Jessie, right? 

The reason behind changing os type from wheezy to Jessie is:

  • Jessie is stable OS from a long time.
  • Security bugs are fixed in Jessie.
  • Repository availability is good for Jessie.

Upgrade Debian Wheezy 6 To Debian Jessie 8

Step1: Install Screen

Screen is a tool which helps you to reconnect to your VPS or Server, in case you are disconnected from it while upgrading Os. Do remember when you're doing any critical work like os upgradation or sync any important code which takes the time to complete then use the screen.

  • apt-get   install   screen

Once screen installation was done, Run the screen command which gives you another console and in this console we are going to work on os upgradation.

  • screen  [Run this command]

To come out of the screen or detached from screen use “Ctrl + AD” and for reattach to screen use “screen -Dr”.

Step 2: Add the Repository

Now open “/etc/apt/sources.list” file and comment all the wheezy related repositories then add below-provided Jessie repository which helps to upgrade OS.

Vim /etc/apt/sources.list

deb http://mirror.cse.iitk.ac.in/debian/ jessie main
deb-src http://mirror.cse.iitk.ac.in/debian/ jessie main

deb http://security.debian.org/ jessie/updates main contrib
deb-src http://security.debian.org/ jessie/updates main contrib

deb http://mirror.cse.iitk.ac.in/debian/ jessie-updates main contrib
deb-src http://mirror.cse.iitk.ac.in/debian/ jessie-updates main contrib

Save and close the file.

Step 3: Update package list & Run the upgrade command

Run the below command to update the package list which we added in sources.list file.

  • apt-get update

After updating the package list run below command which helps to perform a minimal system upgrade.

  • apt-get upgrade

Above command will take some time to complete and while running upgrade it will ask some questions like changing any configuration files etc keep default answer and enter. It will not harm you are previous configuration files.

After completion of minimal upgrade Run the below command to perform a complete system upgrade.

  • apt-get dist-upgrade

If you are not having any important data or working on the fresh system then run below command which removed unwanted packages from server or system.

  • apt-get purge $(dpkg -l | awk '/^rc/ { print $2 }')
  • apt-get autoremove

Step 4 : Reboot System

Now reboot your system or server and check Operating system version with below command,

root@pc:~# lsb_release -a

No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 8.5 (jessie)
Release: 8.5
Codename: jessie

After successful upgradations of Operating system come to the actual part of this article which is up gradation of PHP version.
Once os version upgraded further process of upgrading PHP is easy just follow below few commands and you will have latest PHP version on your system.

Again open “/etc/apt/sources.list” file and add below php repository.

Vim /etc/apt/sources.list

deb http://packages.dotdeb.org jessie all
deb-src http://packages.dotdeb.org jessie all

Once you add the above lines, Download the GPG key which supports PHP repo and adds this key with below command,

  • wget https://www.dotdeb.org/dotdeb.gpg
  • apt-key add dotdeb.gpg

Run below command to update the package list and install PHP7.0 using apt-get install.

  • apt-get update
  • apt-get install php7.0

Check PHP Version

root@pc :~# php -version

PHP 7.0.10-1~dotdeb+8.1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.10-1~dotdeb+8.1, Copyright (c) 1999-2016, by Zend Technologies

I hope you like the article if you find any difficulties while upgrading OS & PHP then please do comment your queries or problem via the comment section, till then stay tuned to techthings.org for more such valuable articles.

Read More:

 

Leave a Reply

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