How to Change PHP Version via .htaccess in cPanel
⚡ How to Change PHP Version via .htaccess in cPanel
Changing the PHP version is often required for application compatibility (e.g., WordPress, Laravel) or to boost performance with newer PHP releases.
You can do it in two ways:
✅ Method 1: Change PHP Version via cPanel Interface
This is the easiest method if you’re changing PHP for a single domain.
-
Log in to cPanel.
-
Find and click “Select PHP Version” (sometimes called MultiPHP Manager depending on your host).
-
From the dropdown, select the desired PHP version.
-
Click Apply or Save.
That’s it — cPanel updates the PHP version for that domain.
✅ Method 2: Change PHP Version via .htaccess
This is useful if you host multiple websites under one cPanel account and want each site to run a different PHP version.
-
Log in to cPanel.
-
Open File Manager.
-
Go to your site’s root directory (usually
public_htmlor the addon domain folder). -
Locate the
.htaccessfile. If it doesn’t exist, create one. -
Edit the file and add this code (for PHP 7.4 as example):
👉 Replace 74 with the version number you need (80 for PHP 8.0, 81 for PHP 8.1, etc.).
-
Save the file and close the editor.
Now your site will run on the selected PHP version.
⚠️ Important Notes
-
The PHP handlers available (like
application/x-httpd-php74) depend on your hosting provider’s setup. Some useMultiPHP Manager, others rely on.htaccess. -
If your host runs CloudLinux with PHP Selector, the
.htaccessline may look different, e.g.:
-
After changing, always verify by uploading a
phpinfo.phpfile:
Share
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Angry
0
Sad
0
Wow
0
