How do I change PHP version?

Corey Seymour
Published: 21 June 2017Last updated: 19 April 2024
Share:

Standard PHP Version

By default, our hosting runs PHP 7+. If you need to switch PHP versions:

  1. Go to My20i.
  2. Select Manage Hosting.
  3. Find the package that you would like to change the PHP Version on and click Options, then Manage.
  4. Under Web Tools, select Change PHP Version.

Available PHP Versions

We support the following PHP versions on our Linux platform:

- PHP 5.3 
- PHP 5.4 
- PHP 5.5 
- PHP 5.6 
- PHP 7.0 
- PHP 7.1 
- PHP 7.2 
- PHP 7.3 
- PHP 7.4 
- PHP 8.0 
- PHP 8.1 
- PHP 8.2 
- PHP 8.3

Note: Version changes are typically instant but may take up to 60 seconds.

Managed WordPress Platform

On our Managed WordPress Platform, we run PHP 7.0 and higher.

Note: PHP versions prior to 7.0 are not supported on the WordPress platform.

Changing PHP Version for Subdirectories/Subdomains

Note: This method is applicable only to shared hosting packages and is not supported on Managed VPS or Cloud Servers.

To host multiple websites on the same package using different PHP versions:

  1. Navigate to the directory where you want to change the PHP version.
  2. Edit or create a .htaccess file.
  3. At the top of the file, add the following line to set the PHP version: 
      - For PHP 7.4: AddHandler x-httpd-php74 .php 
      - For PHP 5.6: AddHandler x-httpd-php56 .php 
      - For PHP 8.3: AddHandler x-httpd-php83 .php

Changing PHP Version for WordPress Staging

To change the PHP version for a WordPress staging site:

1. Navigate to staging_html within your WordPress package. 
2. Add the appropriate AddHandler line to the .htaccess file with the desired PHP version.

Checking PHP Version

To verify the PHP version in use:

  1. Create a new PHP file, such as `info.php`, in the directory where you've changed the PHP version.
  2. Add the following code to the file:
  <?php 
  phpinfo(); 
  ?>

3. Access the file directly in a browser (e.g., staging.domain.com/info.php). The PHP version will be displayed at the top of the page like this:

PHPinfo-header.png

Security Note: PHPinfo files can expose sensitive information. It's advisable to delete the PHPinfo file after checking your PHP version.