How to Switch Php Version in Magento

How to Switch Php Versions in Magento

Magento allows a unique server setup that allows each customer to select which version of PHP to use or switch PHP version in Magento.

Magento 2 supports these Php versions for now: PHP 5.6, PHP 7.0, PHP 7.1, PHP 7.2 & PHP 7.3 (for Magento 2.3.3).

To change the PHP version in Magento in your hosting account, follow the steps below:

  1. Log in to cPanel for your account
  2. Navigate to 1H Software section -> PHP Version Manager
  3. Go to the directory you would like to change the PHP version for (please note that this change applies to subdirectories for it also)
  4. Click on the directory name
  5. Choose the desired PHP version
  6. Click Save

Make the most out of the Managed PHP version service. Automatically update your PHP version to the latest, steady, and secure one when available.

To implement it, select the Managed PHP Version option and Save. It will add the following handler in your .htaccess file:

AddHandler application/x-httpd-recommended-php .php .php5 .php4 .php3

It makes sure that your store is always running on the recommended PHP version without any implementations from your side.

Another option is to apply the changes manually without the help of the PHP version manager in cPanel by adding one of the below directives in the .htaccess file of your store:

Switch to PHP 7.3

Switch to PHP 7.2

Switch to PHP 7.1

Switch to PHP 7.0

Switch to PHP 5.6

Doing so will change the PHP version for that site and all of its subfolders.

If you want a different version of PHP in a subdirectory, create a new .htaccess file in it with the directive for the desired PHP version.

Note: Please make sure that the above PHP versions are installed on your server before applying the above method.

5
(based on 5 Reviews)

Sanjay is a co-founder at Meetanshi. He is a Certified Magento Developer who loves creating Magento E-commerce solutions. When he is not engrossed with anything related to Magento, he loves to play cricket.

Leave a Reply