Switch PHP version in Ubuntu

Best Division

Best Division  @bestdivision

Published On - Last Updated -

Switch PHP version in Ubuntu

You can switch between different versions of PHP on Ubuntu by using a tool called "php version manager" (php-switch). Here are the steps to switch PHP versions using this tool:

Install php-switch:

sudo apt install php-switch

List available PHP versions:

sudo php-switch list

Choose the desired PHP version:

sudo php-switch use <version>

Check the active PHP version:

php -v

Note: You can also switch between PHP versions manually by creating symbolic links in the **/etc/alternatives/** directory. However, this method is more complicated and less recommended.

If you have multiple websites running on your Ubuntu machine and each of them needs a different PHP version, you can either switch between versions for each site using virtual hosts or use tools like php-fpm to run each site on its own PHP version.

Here are some examples of using the **php-switch** tool to switch between different versions of PHP on Ubuntu:

To switch to PHP 7.4:

sudo php-switch use 7.4

To switch to PHP 7.3:

sudo php-switch use 7.3

To switch to PHP 5.6:

sudo php-switch use 5.6

Note: The available PHP versions that you can switch to depend on what is installed on your system. The examples above assume that the desired versions are already installed

Similar Blogs
0 Commentssort Sort By

@abcd 1 days ago

Aquí los que apoyamos a Los del limit desde sus inicios..