How to change or downgrade the php version in ubuntu ?

How to change or downgrade the php version in ubuntu ?

 

This tutorial will help you to downgrade the PHP version in Ubuntu.

To start the downgrade process, First, we need to check the PHP version installed.

How to check the present PHP version

php -v

How to check all the installed PHP version

php -a

Now, We will be removing all the PHP versions from the server

Note:- Before removing you should check all the installed modules so that after changing the version you do not face any issues.



How to remove all the installed PHP version in ubuntu

sudo aptitude purge `dpkg -l | grep php| awk ‘{print $2}’ |tr “\n” ” “`

After removal, we will be installing the required PHP version. But before installation, we need to install the below repository.

Install the repository
Through this repository, you will be able to install any version 5.5 5.6 7.0 7.1 7.2

sudo apt-get install python-software-properties

sudo add-apt-repository ppa:ondrej/php

I am going to install the 5.5 PHP version.

Install the PHP 5.5 version

sudo apt-get install -y php5

There are few dependencies that are very major required with PHP installation. We have listed below.

Dependencies for PHP 5.5

  1. php5-fpm
  2. php5-mcrypt
  3. php5-curl
  4. php5-cli
  5. php5-mysql
  6. php5-gd
  7. php5-intl
  8. php5-xsl

 

Installing the dependencies

sudo apt-get php5-fpm php5-mcrypt php5-curl php5-cli php5-mysql php5-gd php5-intl php5-xsl

One more installation I have tried using the same method. PHP 5.6

Install the php 5.6 version ( do the same steps for other versions as well )

sudo apt-get install php5.6

List of Dependencies PHP 5.6

  1. php5.6-fpm
  2. php5.6-mcrypt
  3. php5.6-mbstring
  4. php5.6-curl
  5. php5.6-cli
  6. php5.6-mysql
  7. php5.6-gd
  8. php5.6-intl
  9. php5.6-xsl
  10. php5.6-zip

 

Leave a comment

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.