FastDomain Web Hosting Help
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. If you do not wish to edit the .htaccess file you can use the cPanel to change your php version as explained in PHP Config.
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 web server. 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.
Rock
- Log in to your FastDomain.com account.
- Click the Advanced tab from the side navigation menu to the left.
- Under the File section, click the File Manager icon.
- Look for the Settings button located towards the upper right corner of your screen.
- Click the Preferences, then toggle the radio button for "Show Hidden Files (dotfiles)."
- Click the Save button when finished.
- Locate the .htaccess file, right-click on it, and select edit.
- At the top of the file, insert the PHP handler for the version you would like to use. If there is a handler in the file already, it should be removed or replaced with your new handler.
- Click Save.
Legacy
- Open the File Manager located on the cPanel.
- Choose Web Root, select Show Hidden Files, and click the submit button on the directory selection popup.
- In the table of files, you should see a file named .htaccess, right-click on it and select the code edit.
- You may get a popup asking about encoding. If so, click the edit button.
- At the top of the file, insert the PHP handler for the version you would like to use. If there is a handler in the file already, it should be removed or replaced with your new handler.
Note: See the Available PHP Handlers section for handlers on each PHP version available. You can copy and paste these directly into the file.
- Click Save.
Once you have saved the file, you can close it. Your account will then use the PHP version you selected.
Available PHP Handlers
Please note: We will be updating to PHP version 8.0 in batches beginning in 2022. Keep an eye out for communications on when your account will be updated and what changes, if any, you will need to make. For more information on updating content for PHP compatibility, read our guide on What to do if your Site Does not Work with Newer Versions of PHP. To learn more about what is changing with PHP 8.0, please see PHP.net's release notes.
The following handlers can be copied and pasted directly into your .htaccess file:
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.3|7.4|8.0|8.1) as default
AddHandler application/x-httpd-php(73|74|80|81) .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.3|7.4|8.0|8.1) Single php.ini as default
AddHandler application/x-httpd-php(73|74|80|74)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(73|74|80|81)CGI as default
AddHandler fcgid(73|74|80|81)-script .php