How To Add Handlers To Change PHP Version - PHP Version Setup | Bluehost Support
Support
  1. bluehost knowledge base

How To Add Handlers To Change PHP Version - PHP Version Setup

Overview

This article will explain how to add a PHP handler to your .htaccess files. This is useful if you want to customize the version of PHP that runs your PHP files by directly editing your .htaccess file. As explained in PHP Config, if you do not wish to edit the .htaccess file, you can use the cPanel to change your PHP version.



Adding the Handler to the .htaccess File

The PHP handler is written into the .htaccess file. The .htaccess file is a hidden file that is read by the webserver. The web server follows any instructions contained within the file. There are many ways to access this file. For the purposes of this article, we will explain accessing it through the File Manager on the cPanel of your hosting account.

Note: Bluehost provides two interface choices for account management: the original 'Bluerock' control panel and the newer 'Account Manager' designed for easier use. Although both offer similar management features, the settings and locations might differ. Refer to 'Account Manager vs. Bluerock' to understand which guidelines to follow.

Account Manager

  1. Log in to your Bluehost control panel.
  2. Click the Hosting tab from the side navigation.
    am-hosting-tab
  3. In the Quick Links section, click on File Manager.
    am-file-manager-v2
  4. Search for the Settings button in your screen's upper right corner.
    cpanel-settings
  5. The Preferences window will appear on your screen. Switch on the radio button for Show Hidden Files (dotfiles). Once you're done, click Save.
    cpanel-show-hidden-folders
  6. Find the .htaccess file in the list of files, right-click on it, and choose the Edit option.
    cpanel-show-hidden-folders
  7. At the top of the file, add the PHP handler corresponding to the version you desire to use. If there's an existing handler in the file, remove it or substitute it with your preferred handler.
Below are the available PHP handlers:
  • PHP 5.4
    php – BEGIN cPanel-generated handler, do not edit
    Set the “ea-php54” package as the default “PHP” programming language.
    <IfModule mime_module>
    AddHandler application/x-httpd-ea-php54___lsphp .php .php5 .phtml
    </IfModule>
    php – END cPanel-generated handler, do not edit
    
  • PHP 5.5
    php – BEGIN cPanel-generated handler, do not edit
    Set the “ea-php55” package as the default “PHP” programming language.
    <IfModule mime_module>
    AddHandler application/x-httpd-ea-php55___lsphp .php .php5 .phtml
    </IfModule>
    php – END cPanel-generated handler, do not edit
    
  • PHP 5.6
    php – BEGIN cPanel-generated handler, do not edit
    Set the “ea-php56” package as the default “PHP” programming language.
    <IfModule mime_module>
    AddHandler application/x-httpd-ea-php56___lsphp .php .php5 .phtml
    </IfModule>
    php – END cPanel-generated handler, do not edit
  • PHP 7.0
    php – BEGIN cPanel-generated handler, do not edit
    Set the “ea-php70” package as the default “PHP” programming language.
    <IfModule mime_module>
    AddHandler application/x-httpd-ea-php70___lsphp .php .php7 .phtml
    </IfModule>
    php – END cPanel-generated handler, do not edit
    
  • PHP 7.1
    php – BEGIN cPanel-generated handler, do not edit
    Set the “ea-php71” package as the default “PHP” programming language.
    <IfModule mime_module>
    AddHandler application/x-httpd-ea-php71___lsphp .php .php7 .phtml
    </IfModule>
    php – END cPanel-generated handler, do not edit
    
  • PHP 7.2
    php – BEGIN cPanel-generated handler, do not edit
    Set the “ea-php72” package as the default “PHP” programming language.
    <IfModule mime_module>
    AddHandler application/x-httpd-ea-php72___lsphp .php .php7 .phtml
    </IfModule>
    php – END cPanel-generated handler, do not edit
    
  • PHP 7.3
    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___lsphp .php .php7 .phtml
    </IfModule>
    php – END cPanel-generated handler, do not edit
    
  • PHP 7.4
    php – BEGIN cPanel-generated handler, do not edit
    Set the “ea-php74” package as the default “PHP” programming language.
    <IfModule mime_module>
    AddHandler application/x-httpd-ea-php74___lsphp .php .php7 .phtml
    </IfModule>
    php – END cPanel-generated handler, do not edit
    
  • PHP 8.0
    php – BEGIN cPanel-generated handler, do not edit
    Set the “ea-php80” package as the default “PHP” programming language.
    <IfModule mime_module>
    AddHandler application/x-httpd-ea-php80___lsphp .php .php8 .phtml
    </IfModule>
    php – END cPanel-generated handler, do not edit
    
  • PHP 8.1
    php – BEGIN cPanel-generated handler, do not edit
    Set the “ea-php81” package as the default “PHP” programming language.
    <IfModule mime_module>
    AddHandler application/x-httpd-ea-php81___lsphp .php .php8 .phtml
    </IfModule>
    php – END cPanel-generated handler, do not edit
    
  • PHP 8.2
    php – BEGIN cPanel-generated handler, do not edit
    Set the “ea-php82” package as the default “PHP” programming language.
    <IfModule mime_module>
    AddHandler application/x-httpd-ea-php82___lsphp .php .php8 .phtml
    </IfModule>
    php – END cPanel-generated handler, do not edit
    
  1. Click Save.

PHP Standard PHP (Default)

All accounts use Standard PHP by default. You can install the default php.ini file to your public_html folder using the PHP Config option inside your cPanel. You can make any changes or modifications to that file and take a guide over the master file. The Standard PHP on the cPanel will need to copy the modified php.ini file into all subdirectories, including PHP files, to use the custom PHP settings.

# Use PHP(7.4|8.0|8.1|8.2) as default 
AddHandler application/x-httpd-php(74|80|81|82) .php 

PHP Single php.ini

The Single php.ini will help you avoid copying the same php.ini file to each directory containing php files. This option changes the PHP handler defined in ~/public_html/.htaccess to indicate that all subfolders use the same php.ini found in public_html/.

# Use PHP(7.4|8.0|8.1|8.2) Single php.ini as default 
AddHandler application/x-httpd-php(74|80|81|82)s .php 

Important Note: The .htaccess PHP handler is looping through all subdirectories unless a subdirectory has a .htaccess file and defines a PHP handler.

PHP FastCGI

The FastCGI for PHP makes all your PHP applications tenacious and uses only one php.ini file in the public_html directory. Also, there is no per-request startup and initialization indirect cost. 
This PHP makes possible the development of applications that would otherwise be ineffective within the CGI paradigm (e.g., a huge PHP script or an application that requires a connection to one or more databases). Using the PHP FastCGI option makes all your PHP applications run through mod_fcgid instead of mod_suphp.

# Use PHP(74|80|81|82)CGI as default 
AddHandler fcgid(74|80|81|82)-script .php 

If you need further assistance, feel free to contact us via Chat or Phone:

  • Chat Support - While on our website, you should see a CHAT bubble in the bottom right-hand corner of the page. Click anywhere on the bubble to begin a chat session.
  • Phone Support -
    • US: 888-401-4678
    • International: +1 801-765-9400

You may also refer to our Knowledge Base articles to help answer common questions and guide you through various setup, configuration, and troubleshooting steps.