DEV Community

Brent Vanwildemeersch
Brent Vanwildemeersch

Posted on • Edited on

How to change your PHP version on Ubuntu 22.04

Info

This is a guide to change your PHP version through the command line on Ubuntu 22.04

Installed versions list

To list all the installed PHP versions on your local device, use the following command :

sudo update-alternatives --config php
Enter fullscreen mode Exit fullscreen mode

Change active PHP version

To change your currently used PHP version to a different version (that is installed), you can use the following command:

sudo update-alternatives --set php /usr/bin/php${version}
Enter fullscreen mode Exit fullscreen mode

Top comments (3)

Collapse
 
cavo789 profile image
Christophe Avonture

Hi ! On fact this question didn't exist anymore as soon as you use Docker. Just use the image with the version you want and tadaaa. If you are a web developer, take time to follow a tutorial, you'll not regret I think.

Collapse
 
vanwildemeerschbrent profile image
Brent Vanwildemeersch

Thanks for the tip, will look into it

Collapse
 
justpthaiit profile image
Phạm Tiến Hải

you save my day