🔥 Just Launched! Werra Premium Template for HyväSee it in Action

How to Switch Php Version in Magento

By Sanjay JethvaUpdated on Jul 14, 2025 2 min read

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

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

Switch to PHP 7.2

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

Switch to PHP 7.1

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

Switch to PHP 7.0

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

Switch to PHP 5.6

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

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.

Related Blogs:

Sanjay Jethva Full Image
Article bySanjay Jethva

Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe. His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.