close

How to Switch PHP versions on Commandline ubuntu

Hello Guys How are you all? Hope you all are fine. Today In this tutorial we are going to learn How to Switch PHP versions on Commandline ubuntu. Here We will talk about all possible ways to Switch PHP versions on Commandline ubuntu. So without wasting your time, Let’s start this article.

How to Switch PHP versions on Commandline ubuntu?

  1. How to Switch PHP versions on Commandline ubuntu

    To Switch PHP versions on Commandline ubuntu List all available versions and choose from them use this command sudo update-alternatives –config php And then do manually sudo a2dismod php7.1 to disable and use this command to enable sudo a2enmod php5.6

  2. Switch PHP versions on Commandline ubuntu

    To Switch PHP versions on Commandline ubuntu List all available versions and choose from them use this command sudo update-alternatives –config php And then do manually sudo a2dismod php7.1 to disable and use this command to enable sudo a2enmod php5.6

Method 1: Manual Switching

When You need to use PHP 7.1 then use this command line

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

Also, you can

sudo update-alternatives --set php /usr/bin/php7.1
sudo update-alternatives --set phar /usr/bin/phar7.1
sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.1

Method 2: Switch From PHP 7.1 => PHP 5.6

When You need to use PHP 5.6 then use this command line

sudo a2dismod php7.1
sudo a2enmod php5.6
sudo service apache2 restart
sudo update-alternatives --set php /usr/bin/php5.6

Method 3: Interactive switching mode

sudo update-alternatives --config php
sudo update-alternatives --config phar
sudo update-alternatives --config phar.phar

Method 4: enable and disable

List all available versions and choose from them.

sudo update-alternatives --config php

And then do manually

sudo a2dismod php7.1 //disable
sudo a2enmod php5.6  //enable

Summary

It’s all About How to change PHP versions on Commandline ubuntu issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you?

Also, Read

Please Rate Our Solution to Motivate Us For Give Our Best

Leave a Comment