How to Add Handlers to Change PHP Version in File Manager
Need to change your PHP version in cPanel? It's easier than you think! While Bluehost automatically sets your account to the recommended PHP version for optimal performance, you might need to switch things up for compatibility with a specific website or application. In this article will walk you through the easy steps on how to add handlers to change your PHP version.
Adding the Handler to the .htaccess File
The PHP handler is written into the .htaccess file, which is hidden and read by the web server. The 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 your hosting account's cPanel.
Account Manager
- Log in to your account via Bluehost Account Manager.
- Click the Hosting tab from the side navigation.
- In the Quick Links section, click on File Manager.
- Search for the Settings button in your screen's upper right corner.
- The Preferences window will appear on your screen. Switch on the radio button for Show Hidden Files (dotfiles). Once you're done, click Save.
- Find the .htaccess file in the list of files, right-click on it, and choose the Edit option.
- 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 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
- PHP 8.3
php – BEGIN cPanel-generated handler, do not edit Set the “ea-php83” package as the default “PHP” programming language. <IfModule mime_module> AddHandler application/x-httpd-ea-php83___lsphp .php .php8 .phtml </IfModule> php – END cPanel-generated handler, do not edit
- PHP 8.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(8.1|8.2|8.3) 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(8.1|8.2|8.3) Single php.ini as default
AddHandler application/x-httpd-php (81|82|83)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 allows all your PHP applications to run through mod_fcgid instead of mod_suphp.
# Use PHP(81|82|83)CGI as default
AddHandler fcgid(81|82|83)-script .php
Summary
And that's it! You have now learned how to add handlers to change the PHP version in cPanel by including handlers in your .htaccess file. Remember to test the entire site for any changes and then look for issues. If there is a problem, roll back to the previous version, and you can always open up a support ticket with Bluehost to be walked through the process. Happy coding!
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.