1. Knowledge Base
  2. >
  3. Results
  4. >
  5. How to Update the PHP Version

How to Update the PHP Version

 

Suppose you ever encounter problems with the way your server handles PHP packages or find WordPress requesting that you upgrade your PHP version. In that case, it is helpful to know how to view and modify your server's PHP configuration. In this article, we have provided a few options on how to update your PHP configuration on your hosting account.

Starting December 2020, HostGator will update the available PHP versions on our hosting servers. PHP 7.4 will be available on shared hosting. We recommend that you upgrade all your website installations and applications to be compatible with the newest PHP version. Please be aware that older versions of PHP will no longer be supported as we work on updating accounts.

Why Is It Important To Update Your Site's PHP Version?

Updating your site's PHP version is vital for the security of your website. Whenever a new PHP version is released, it comes with the latest security patches that will be implemented.

What Version of PHP Does HostGator Support? 

HostGator offers PHP 7.0 through PHP 7.4 on our shared hosting platforms.

Note: Some Legacy Dedicated Servers may not have all the PHP versions available.

What Are the Steps I Need To Update My Site's PHP Version?

If your website needs a different PHP version, you will want to log into your cPanel to manage what version the site uses.

Most customers will have the MultiPHP Manager available in their cPanel and should follow the instructions for Option 1 below to manage your PHP versions.
If you do not have the MultiPHP Manager available in your cPanel, then you will have access to PHP Selector and can follow the directions for Option 2 below.


Option 1 - MultiPHP Manager


You may find some links below that will redirect you to your cPanel and its features provided that the following conditions are met:
  • You are logged into your Customer Portal. You can also log in after clicking the link.
  • The hosting package you are attempting to access is either Shared or Cloud.

MultiPHP Manager Instructions

  1. Log into cPanel. 
  2. Select MultiPHP Manager in the Software section.
    cPanel MultiPHP Manager Plugin
  3. Select the domain you want to update by checking the box on its left side.
    MultiPHP Manager Select Domain
  4. Choose your preferred PHP version from the drop-down, then click Apply.
    MultiPHP Manager Select PHP Version
  5. There will be a pop-up in the upper right corner, notifying you that the change was successful.
    PHP Version Change Successful
If you previously used the PHP Selector to change your PHP version, there may be a handler in your .htaccess file that needs to be removed similar to this one:5

Use PHPedge as default
AddHandler application/x-httpd-php-edge .php
<IfModule mod_suphp.c>
    suPHP_ConfigPath /opt/phpedge/lib
</IfModule> 

For specific instructions on how to fix "Missing MySQL Extension" errors, please see the instructions below.


Option 2 - PHP Selector

The PHP Selector allows users on Shared and Reseller servers to easily enable a specific PHP version for a site without manually adding a handler to the .htaccess file. To update the PHP version of a site using the PHP Selector, please check this video guide ⤵.


PHP Selector Instructions

  1. Log into cPanel.
  2. In the Software section, click the PHP Selector icon.
    cPanel PHP Selector Plugin
  3. Navigate to the directory in which you'd like to update the PHP version. The document root for the primary site on your account is located in the public_html folder.
    cPanel PHP Configuration
  4. From the dropdown menu, select the version of PHP you want to use, then click Update.
    cPanel Select PHP Version
    Caution: If your site's scripts rely on older functions of PHP, which are no longer available in the latest stable version being used on the server, you may encounter compatibility issues when the PHP is automatically updated.
Note: When using PHP Selector, updates are applied recursively. This means any update you apply to a directory will also apply to all subdirectories unless you apply a different directive to one of those subdirectories. Therefore, to use a different PHP version for an addon domain, you would need to navigate to the document root for the addon domain and select the appropriate version of PHP.

Are You Getting a "Mysql Extension" Error? Please Click the Link Below for More Information. 

Important Note:

This workaround will work if you previously used the PHP Selector to manage the PHP version for your site, then recently used the new MultiPHP Manager to update the PHP.

This section will discuss the workaround for your WordPress website if you encounter an issue similar to this one:

Missing MySQL Extension Error

How To Fix "Missing MySQL Extension" Error

This error can be fixed by following the steps in the video below, and we've included a synopsis of the steps.


Troubleshooting MultiPPHP Error

You may find some links below that will take you directly to your cPanel provided that the following conditions are met:

  • You are logged into your Customer Portal. You can also log in after clicking the link.
  • The hosting package you are attempting to access is either Shared or Cloud. The link will only work for the first type of this package listed in the billing account.
  1. Log into cPanel.
  2. Locate and select File Manager.
  3. Locate and open the public_html folder.
    The public_html is the document root for your primary domain, which is why we're using it for this example. If you are doing this for a Subdomain or an Addon domain, you will want to go to that domain's document root instead.
  4. Locate the .htaccess file, right-click on it, and select View.

    How to Locate your .htaccess

    Here is a video guide to assist you in locating and editing your .htaccess file.

    The steps in the video are outlined below.

    To access the .htaccess file:

    1. Log into cPanel.
    2. In the Files section, click on the File Manager to open. 

      HostGator cPanel - File Manager

    3. To display the .htaccess file, click Settings in the upper right-hand corner.
    4. Make sure the Show Hidden Files (dotfiles) is checked.
    5. Click Save. This will refresh the page, and all files starting with a "." (dot) will be displayed.

      HostGator - cPanel - File Manager - Show Hidden Files

    6. Click Save.
    7. You can now select your domain's document root. For this example, we will use the public_html folder.
    8. Inside your public_html, look for the .htaccess file. You may need to scroll your cursor a little bit to find it. 
  5. In your .htaccess, you should see two entries for PHP handlers. First, you'll have to identify the one that needs to be removed.

    The old PHP handler you'll want to remove will look similar to one of these:

    
    # Use PHP71 as default
    AddHandler application/x-httpd-php71 .php
    <IfModule mod_suphp.c>
        suPHP_ConfigPath /opt/php71/lib
    </IfModule>
    	
    
    #Use PHPedge as default
    AddHandler application/x-httpd-php-edge .php
    <IfModule mod_suphp.c>
        suPHP_ConfigPath /opt/phpedge/lib
    </IfModule>
    	

    The one you want to keep will look like the one below. You will notice that it says "cPanel-generated handler, do not edit" in it as it was previously created by the MultiPHP Manager.

    
    # php -- BEGIN cPanel-generated handler, do not edit
    # Set the “ea-php73” package as the default “PHP” programming language.
    <IfModule mime_module>
      AddHandler application/x-httpd-ea-php73 .php .php7 .phtml
    </IfModule>
    # php -- END cPanel-generated handler, do not edit
    	

    These PHP handlers are conflicting with each other; that is why your site is showing an error. You will need to remove the old PHP handler so the .htaccess will read the MultiPHP handler code instead.

  6. Once you've identified these PHP handlers, create a backup of your .htaccess file before making any changes.

    How to Create a Backup of your .htaccess

    HostGator strongly recommends creating a backup of the .htaccess file before making any changes to it. Below are the steps on how to create a backup of your .htccess.

    1. In your directory, locate the .htaccess file.
    2. Right-click on it and select Copy.
    3. In the pop-up, it will provide the beginning of the path of where to store the backup. It will begin with /public_html, and you'll fill in the rest so that it reads /public_html/.htaccess.bak, then click Copy File(s).
    4. Now you'll see the backup file in the main window named .htaccess.bak. You can always restore this by removing the .bak extension.
  7. Right-click on the .htaccess and click Edit.

    How to Edit your .htaccess

    To edit the .htaccess File:

    1. Right-click on the .htaccess file and click Edit from the menu. Alternatively, you can click on the .htaccess file and then click on the Edit icon at the top of the page.

      HostGator -  cPanel - File Manager - .htaccess File - Edit

    2. A dialogue box may appear asking you about encoding. Just click Edit to continue. The editor will open in a new window.

      HostGator - cPanel - File Manager - .htaccess File - Edit Confirmation Prompt

    3. Do the necessary edits. 

      HostGator - cPanel - File Manager - .htaccess File - Edit Code

    4. Click Save Changes in the upper right-hand corner when done.

      HostGator - cPanel - File Manager - .htaccess File - Save Changes

  8. To disable the PHP handler that you don't want, you can simply add a "#" at the beginning of each line, as we've done in the example below.
    
    #Use PHPedge as default
    #AddHandler application/x-httpd-php-edge .php
    #IfModule mod_suphp.c>
    #   suPHP_ConfigPath /opt/phpedge/lib
    #/IfModule>
    	
    Note: There may be more than one old PHP Handler entry in your .htaccess file. Repeat Step #8 for any additional entries. You should only have one entry that begins and ends with:
    # php -- BEGIN cPanel-generated handler, do not edit
    
    # php -- END cPanel-generated handler, do not edit
    
  9. Click Save Changes and then Close to exit the editor.
  10. Pull up your site to check if the error is already gone.
If the instructions above do not work and your site is still displaying an error, please try and continue with these steps.
  • Search for the .htaccess file outside your website's document root. This is the first .htaccess you saw when you opened the File Manager and before you clicked the public_html folder in Step 3 ⤴.
  • Go ahead and open that .htaccess. Check if there is an old PHP handler in there, as shown in Step 5. If there is, disable it by adding a # as shown in Step #8 ⤴. Pull up your site again to check.
  • If the error is still there, go to your cPanel's MultiPHP Manager, and select your website name. Then, set your PHP version to inherit from the dropdown menu.
Need a bit more help? Contact HostGator support via phone or Live Chat, and we will be happy to assist you!