> ## Documentation Index
> Fetch the complete documentation index at: https://kb.hosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Changing the PHP version for a specific directory

> Learn to set a specific PHP version for a directory on shared, reseller, or Turbo hosting, enabling PHP 8.0 for your applications.

This article describes how to set the PHP version for a specific directory. Normally, when you set the PHP version in cPanel [using the PHP Selector](/docs/changing-php-versions-and-settings-in-cpanel), that version is used for the entire account. However, if you want to use a different PHP version in a specific directory, you can do so.

<Warning>
  **Important**

  The information in this article **only** applies to accounts on servers that are running CloudLinux. This includes:

  * Shared hosting accounts.

  * Reseller hosting accounts.

  * Turbo Web hosting accounts.

  * Managed VPS and managed Dedicated server accounts activated **in May 2023 or after**.

  For more information about how to determine if your account uses CloudLinux, please see [this article](/docs/determining-if-your-hosting-account-uses-cloudlinux).
</Warning>

## Changing the PHP version for a directory

To change the PHP version for a specific directory, follow these steps:

1. Using your preferred text editor, create a file named *.htaccess* in the directory where you want to use a different PHP version.

2. Copy the following text:

   ```
   <FilesMatch ".(php4|php5|php3|php2|php|phtml)$">
       SetHandler application/x-httpd-alt-phpXX___lsphp
   </FilesMatch>
   ```

3. Replace ***XX*** with the PHP version you want to use in the directory. You can use any PHP version that is listed in the cPanel PHP Selector. For example, to enable PHP 8.1, you would type `SetHandler application/x-httpd-alt-php81___lsphp`. (Make sure you do not include the period in the version number. For example, for PHP version 7.4, type `74`.)

4. Paste the modified text into the *.htaccess* file.

5. Save the *.htaccess* file. The new PHP version takes effect immediately.

   > 👍 Tip
   >
   > To verify the new configuration, create a PHP file that [runs thephpinfo()function](/docs/view-php-settings). Load the file in your web browser, and confirm the PHP version. For example:
   >
   > ![phpinfo() output showing the currently loaded PHP version.](https://static.hosting.com/kb/kb-php-version-phpinfo.png)

<Warning>
  **Important**

  If you enabled additional PHP extensions for the default PHP version in cPanel, check the output from the **phpinfo()** function and confirm that the extensions have also been loaded for the custom PHP version in the directory. If the extensions have not been loaded, please open a support ticket at [https://my.hosting.com](https://my.hosting.com) and we will resolve the issue for you.
</Warning>

## More information

For more information about the **phpinfo()** function, please visit [https://www.php.net/manual/en/function.phpinfo.php](https://www.php.net/manual/en/function.phpinfo.php).

## Related articles

* [Changing PHP versions and settings using PHP Selector](/docs/changing-php-versions-and-settings-in-cpanel)

* [PHP script basics](/docs/php-script-basics)

* [Viewing PHP settings](/docs/view-php-settings)

* [What is PHP?](/docs/what-is-php)
