This site utilizes JavaScript to function correctly. Looks like it's disabled on your browser. Please enable it for your best experience.

For instructions on enabling JavaScript, click here

Skip to main content

Just Host 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

  1. Log in to your Justhost.com  account.
  2. Click the Advanced tab from the side navigation menu to the left.
  3. Under the File section, click the File Manager icon.
  4. Look for the Settings button located towards the upper right corner of your screen.
  5. Click the Preferences, then toggle the radio button for "Show Hidden Files (dotfiles)."
  6. Click the Save button when finished.
  7. Locate the .htaccess file, right-click on it, and select edit.
  8. 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.
  9. Click Save.

Legacy

  1. Open the File Manager located on the cPanel.
  2. Choose Web Root, select Show Hidden Files, and click the submit button on the directory selection popup.
  3. In the table of files, you should see a file named .htaccess, right-click on it and select the code edit.
  4. You may get a popup asking about encoding. If so, click the edit button.
  5. 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.

  6. 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
Knowledgebase Article 408,421 views bookmark tags: htaccess php


Was this resource helpful?

Did this resolve your issue?


Please add any other comments or suggestions about this content:





Recommended Help Content

What are Apache Handlers? How do I setup customized Apache Handlers?
Knowledgebase Article 220,032 views tags: apache handler handlers

How to change your PHP version in your hosting account
Knowledgebase Article 903,955 views tags: config php selection version

This article will explain how to use Easy Apache to recompile Apache. This is useful if you want to change the version of PHP or change other PHP and Apache settings.
Knowledgebase Article 135,672 views tags: apache build compile dedi dedicated easy modules version vps

Related Help Content

Changing PHP versions, load custom Apache mods, and other Apache/PHP customizations
Knowledgebase Article 154,826 views tags: easyapache php vps whm

This article will explain how to access Microsoft Outlook online or directly from your Desktop.
Knowledgebase Article 48,093 views tags: access add create login microsoft office setup

There are many ways that you can transfer files and folder to and from your hosting account. We highly recommend using an FTP (File Transfer Protocol) program to quickly upload and download files. We
Getting Started Article 327,802 views tags: file files filezilla manager setup

The redirection of www.yourdomain.com/default.html or index.html to http://www.yourdomain.com/index.php?act=whatever redirects it to http://www.yourdomain.com/index.php%3fact=whatever In other words,
Knowledgebase Article 1,037,029 views tags: htaccess messing mod php redirect redirects rewrite variable variables

How do I change the PHP environment for my site with php.ini?
Knowledgebase Article 810,428 views tags: configuration ini php server

500 Internal Server Error when installing via the MOJO Marketplace installer.
Knowledgebase Article 285,115 views tags: cpanel errors htaccess panel php script simpel

Executing php code within a HTML document
Knowledgebase Article 235,496 views tags: addhandler addtype handler mime parse php sethandler

Explains how to edit the .htaccess
Knowledgebase Article 371,132 views tags: htaccess

** Google ad credits are only available to customers in the United States, Canada, and the United Kingdom at this time.

¹ VAT (Value Added Tax) is not included in our advertised price and will be charged separately and itemized on invoices and billing information. Standard VAT rates based on EU Member State regulations may apply. Learn more.