Knowledge Base


How to Add Handlers to Change PHP Version in File Manager (and Stop 503 Errors)

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 DA.

  1. Log in to your control panel.
  2. Click File Manager under the System Info & Files section
  3. In the top-right corner, click Settings and check the box for Show Hidden Files (dotfiles). Click Save.
  4. Navigate to the public_html directory and locate the . htaccess file.
  5. Right-click the file and select Edit.
     


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, comment it or substitute it with your preferred handler.


Below are the available PHP handlers:


PHP 8.1


               #php – BEGIN DA-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 DA generated handler, do not edit
             
PHP 8.2


              # php – BEGIN DA-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 DA generated handler, do not edit
             
PHP 8.3


               #php – BEGIN DA 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 DA generated handler, do not edit
             
Click Save.


PHP Standard PHP (Default)


All accounts use Standard PHP by default.  The Standard PHP on the control panel 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 your DA 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 Usijali Hosting to be walked through the process. Happy building!

 

Please rate this article to help us improve our Knowledge Base.

0 0