ItSolutionStuff.com

How to Change PHP Version in Ubuntu Server?

By Hardik Savani • May 14, 2024
Ubuntu Server

Hi,

This article goes in detailed on how to change php version in ubuntu. you can see how to change php version command line. if you have question about how to change php version in ubuntu 20.04 then i will give simple example with solution. I’m going to show you about change php version linux.

If you installed multiple php version in your ubuntu system or server and you need to change default php version then i will help you with different ways to change php version in ubuntu 21.10, ubuntu 21.04, ubuntu 20.04, ubuntu 18.04 and ubuntu 16.04.

let's see commands one by one.

Way 1: Change PHP Version

you can change php version by following command:

sudo update-alternatives --config php

you have to choose from list as bellow:

now let's restart server:

sudo service apache2 restart

Way 2: Change PHP Version

Here, you need to a2dismod old version and a2enmod new php version so let's run following command:

sudo a2dismod php7.3

sudo a2enmod php7.4

now let's restart server:

sudo service apache2 restart

Way 3: Change PHP Version

You can direct change php version by following command:

sudo update-alternatives --set php /usr/bin/php7.4

now let's restart server:

sudo service apache2 restart

i hope it can help you...

Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

šŸ“ŗ Subscribe on YouTube

We Are Recommending You

ā˜…

How to Install MySQL in Ubuntu Server?

Read Now →
ā˜…

How to Install PHP in Ubuntu Server?

Read Now →
ā˜…

How to Install Apache Web Server on Ubuntu Server?

Read Now →
ā˜…

Node JS CRUD with MySQL Tutorial Example

Read Now →
ā˜…

How to Connect SSH using ppk File Ubuntu?

Read Now →
ā˜…

How to Connect to a Remote Server using SSH on Ubuntu?

Read Now →
ā˜…

How to Upgrade PHP Version from 7.4 to 8 in Ubuntu?

Read Now →
ā˜…

How to Export Mysql Database using Command Line in Ubuntu?

Read Now →
ā˜…

How to Import Database in Mysql using Command Line in Ubuntu?

Read Now →
ā˜…

How to Upgrade PHP Version from 7.2 to 7.3 in Ubuntu?

Read Now →
ā˜…

How to Enable Apache mod_rewrite Module in Ubuntu?

Read Now →