Skip to main content

Change the PHP version

We offer multiple PHP versions which can be selected in cPanel

Updated over a week ago

Different websites may need different PHP versions. You can choose the version needed by your website with just a few clicks in your cPanel interface. Additionally, different domains or subdomains within a single account might require specific PHP versions to meet application requirements.

Prerequisites

  • Access to cPanel or

  • Access to Funio Hub

Task completion: 5 minutes

Expertise: beginner

How to do it?

  1. Log in to your cPanel.

  2. In the Software section, choose Select PHP Version.

  3. You will be able to choose the version. See available versions.

You can also enable essential PHP modules via cPanel to ensure your website's functionality. Navigate to Select PHP Version, switch to the Options tab, and select required modules such as gd, fileinfo, imagick, zip, and intl by checking their boxes. Saving the settings applies these changes.

Note: Personalized parameters, such as modules and specific custom PHP values are per PHP version. This means that if you change from 5.2 to 5.6, the custom values and modules you may have activated will not be active in the new version. Make sure you activate the modules you wish to use and configure PHP values as required on this same page.

Advanced PHP Version Management

Setting PHP Versions for Domains and Subdomains Using .htaccess

In cPanel, you can specify different PHP versions for separate domains or subdomains by editing the .htaccess file in the corresponding root directory. For instance, to assign PHP 8.2, you can include the following snippet:

<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">
  SetHandler application/x-httpd-alt-php82___lsphp
</FilesMatch>

Make sure the .htaccess is correctly placed, such as in the directory specific to a subdomain (e.g., [sub.yourdomain.com](https://sub.yourdomain.com)). Save these changes to apply the selected PHP version.

Advanced Usage with CloudLinux PHP Selector

If your server uses the CloudLinux PHP Selector, PHP versions for individual subdomains cannot be managed directly via cPanel. However, using .htaccess as outlined above remains effective. This approach adds flexibility for advanced configurations.

Summary

By using tools like cPanel and .htaccess, you can manage distinct PHP versions and modules for different websites, domains, and subdomains. This ensures that each application operates within its optimal PHP environment, offering both beginner-friendly and advanced management techniques.

References

Did this answer your question?