Ensuring your website operates on the right PHP version is essential for optimal performance. In this guide, we’ll walk through two methods of changing PHP versions using CloudLinux’s Select PHP Version feature and via .htaccess. These methods are applicable to various web applications, not just limited to WordPress.
Method 1: Using CloudLinux’s Select PHP Version
Step 1: Log in to cPanel
- Log in to your cPanel account.
- Navigate to the ‘Software’ section.
- Click on ‘Select PHP Version.’
Step 2: Choose PHP Version
- Select the domain(s) for which you want to change the PHP version.
- Choose the desired PHP version from the dropdown menu.
- Click ‘Apply.’
Step 3: Verify Changes
- Visit your website.
- Check for any compatibility issues.
- Ensure the PHP version has been updated.
Method 2: Setting Custom PHP Version via .htaccess for multiple sites
Step 1: Locate the .htaccess File
- Access your hosting control panel and navigate to the ‘File Manager.’
- Make sure you have enabled the Show Hidden Files/Folders option in File Manager from the menu in the top right. Here is the guide for it!
- Find the root directory of the addon domain or subdomain where you want to set a custom PHP version.
- In the ‘File Manager,’ locate the .htaccess file and right-click to edit it. If it doesn’t exist, create a new one.
Step 2: Edit .htaccess File
- Alternatively, use the text editor within the ‘File Manager’ to create and edit the .htaccess file.
Step 3: Add Custom PHP Version
To set a PHP version, add the following line:
AddHandler application/x-httpd-alt-php74___lsphp .PHP
Replace 74 with your desired PHP version, ensuring compatibility with your web application. For example, for PHP 8.1 use 81 or 80 for PHP 8.1.
Step 4: Save and Verify
- Save the changes to the .htaccess file.
- Visit your website and check for any compatibility issues.
- If you see the site is broken then verify that the PHP version has been updated as intended.
In some cases, you will have to connect with Web Developers to ensure which PHP version is required.
Share Your Comments & Feedback