3 ways to run a different PHP version in cPanel ?

3 ways to run a different PHP version in cPanel ?

PHP is a widely-used open source general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. PHP is a widely-used, free, and efficient . Sometimes we need to run a different PHP version for our project, and cPanel has some built-in functions that allow us to change the PHP Version directly. PHP 8.1, released in 2021, brings major new features such as  Enums, Fibers, Intersection Types, readonly properties.

With cPanel default Select PHP Version and MultiPHP Manager ,it is easy to run a different PHP version for a Domain, an Addon domain, and a Subdomain.

Run a different PHP version with Select PHP Version.

If you want to change the PHP Version of your Main/Primary domain, you can do so by using the Select PHP Version option. To modify PHP’s version and extension to meet your needs, follow these steps:

STEP 1: Login to cPanel.

STEP 2: Go to the Software section and click on the Select PHP Version .

run a different PHP version in cPanel

STEP 3: From this step, you can choose the PHP Version and PHP Extension based on your needs.

change Php extension and add extension

Run a different PHP version with MultiPHP Manager.

If you have our Maximum or Ultimate plan, you can host multiple websites using Addon Domain. So using MultiPHP Manager, you can change the PHP Version of your Domain, Addon Domain or Subdomain.

Follow these steps to change the PHP version according to your requirements:

STEP 1: Login to cPanel.

We are creating a Subdomain, test.risenepal.com, and we want to change the PHP Version of test.risenepal.com to 8.0. Originally, the PHP Version of test.risenepal.com was the same as the Primary domain risenepal.com, which is 7.4.

creating a subdomain

STEP 2: Navigate to the Software section and Select MultiPHP Manager

MultiPHP Manager of cPanel


STEP 3: Here you can see the list of your Domains, Addon domains, and Subdomains. Select the Domain/Addon/Subdomains for which you want to change the PHP Version, and then click on “Apply.” Here I have changed the test. risenepal.com subdomains’ PHP Version to 8.0.

Selecting PHP version per Domain

STEP 4: You can see that we were able to successfully change the Domain and Subdomain’s PHP Version.

Changed PHP version of domain and subdomain

Run a different PHP version with .htaccess file.

MultiPHP Manager is not available on all cPanel interfaces. As a result, we must change the PHP Version of the Addon Domain and Subdomain manually via the .htaccess file. An .htaccess file is used for an Apache web server as a way to configure the details of your website without altering the server configuration files.

Follow these steps to change the PHP version according to your requirements:

For example, I have made a Subdomain named example.risenepal.com, which has PHP Version 7.3.33 as you can see below. Here I have created a sample PHP file name example. php inside the subdomain to check the PHP Version of this Subdomain.

Creating a subdomain
checking PHP version of subdomain

STEP 1: Go to the Files section, there you will find the File Manager section, and click on that.

File manager section of cPanel

STEP 2: On the left side, you will see the Subdomain name you created now, inside that folder, we must create an .htaccess file

creating .htaccess file for subdomain

STEP 3: Now Select .htaccess file and select Edit.

Editing .htaccess file

STEP 4: Paste the below code in editor and click on save changes.

AddHandler application/x-httpd-alt-php81___lsphp .php
Adding code to .htaccess file

STEP 5: As you can see, the PHP Version of Subdomain example.risenepal.com has been changed to 8.1, which was previously 7.3.

Checking PHP version
PHP versioncode
php 5.2AddHandler application/x-httpd-alt-php52___lsphp .php
php 5.6AddHandler application/x-httpd-alt-php56___lsphp .php
php 7.0AddHandler application/x-httpd-alt-php70___lsphp .php
php 7.1AddHandler application/x-httpd-alt-php71___lsphp .php
php 8.1AddHandler application/x-httpd-alt-php81___lsphp .php

Congratulation You have successfully changed the PHP Version using a different method. Now you can change the PHP Version according to your convenience.

If you find any difficulty then you can contact us through a Support Ticket or live chat. We are there for you.

Leave a Reply

Your email address will not be published. Required fields are marked *