Loading...

Knowledge Base

How to Update PHP Version: Manage php.ini and PHP Handlers

Updating your PHP version is essential for keeping your website secure and running well. This guide will teach you how to update your PHP version, create a new php.ini file, and manage PHP handlers. You'll also learn how to set up PHP FastCGI and the differences between available PHP versions. This will help your website run smoothly and efficiently.

Update PHP Version

To keep your website running smoothly, update the PHP version in your cPanel account. Check our guide on What is the Latest Supported PHP Version? to learn more about updating the PHP version.

Add PHP handlers

You can customize the PHP versions that run PHP files by directly editing the .htaccess file. Once the .htaccess file has been created or located:

  1. Access the File Manager.
  2. Find the .htaccess file in the list of files, right-click on it, and choose the Edit option.
    File Manager - Edit

     

  3. 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 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 
          
    • 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 
          
  4. Once you have added one of those codes, click Save. The account will then use the PHP version you selected.

CGI Type

Below are options to consider when selecting the PHP type.

Standard PHP (Default)

By default, all accounts use standard PHP. A PHP script will use the server's master php.ini configuration file with standard PHP selected if the script's directory does not contain a php.ini file. Each hosting account initially has a copy of the php.ini file in the public_html directory. You may make any changes to this file, and the modification will take precedence over the master file. With standard PHP selected in the cPanel, you will need to copy the modified php.ini file into all subdirectories containing PHP files to use the custom PHP settings.

PHP Single php.ini

To avoid copying the same php.ini file to each and every directory containing PHP files, you may select the PHP Single php.ini. 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/.

PHP FastCGI

Using the PHP FastCGI option allows all your PHP applications to run through mod_fcgid instead of mod_suphp. FastCGI uses only one php.ini file located in the public_html directory. 

Summary

Keeping your PHP version up to date is essential for maintaining the security and performance of your website. By learning how to generate a new php.ini file, configure PHP handlers, and effectively utilize PHP FastCGI, you can optimize your site for better functionality and compatibility. As you prepare to update your PHP version, be sure to support the latest versions of PHP, like PHP 8.1 and above, so your site will run correctly.

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.

Did you find this article helpful?

 
* Your feedback is too short

Loading...